Skip to content

Support arbitrary diodes in DiodePowerMerge#491

Merged
ducky64 merged 6 commits into
masterfrom
diode-fix
May 20, 2026
Merged

Support arbitrary diodes in DiodePowerMerge#491
ducky64 merged 6 commits into
masterfrom
diode-fix

Conversation

@ducky64
Copy link
Copy Markdown
Collaborator

@ducky64 ducky64 commented May 20, 2026

Replaces the static 2-input version with a generator.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates DiodePowerMerge to support an arbitrary number of diode-isolated power inputs by converting it from a fixed 2-input Block into a GeneratorBlock driven by a requested Vector of inputs, and adds a unit test to validate behavior and refinements.

Changes:

  • Refactor DiodePowerMerge into a generator with pwr_ins: Vector[VoltageSink], dynamically instantiating diodes per requested input.
  • Add deprecated compatibility accessors for legacy pwr_in1 / pwr_in2.
  • Add a new unit test validating voltage/current propagation and diode footprint refinement.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
edg/parts/PowerConditioning.py Replaces the fixed 2-input DiodePowerMerge with a generator-driven multi-input implementation and adds deprecation shims.
edg/parts/test_diodemerge.py Adds a compile-time unit test covering multi-input merge behavior and diode refinement propagation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread edg/parts/PowerConditioning.py Outdated
pwr_in = self.pwr_ins.append_elt(VoltageSink(current_draw=self.pwr_out.link().current_drawn), name)
self.diodes[name] = diode = self.Block(
Diode(
reverse_voltage=(0, pwr_in.link().voltage.upper() - input_hull.lower()),
Comment on lines +83 to +97
def __getattr__(self, item: str) -> Any:
if item == "pwr_in1":
warnings.warn(
f"Use pwr_ins.request(...) instead.",
DeprecationWarning,
stacklevel=2,
)
)
self.diode2 = self.Block(
Diode(
reverse_voltage=(0, self.pwr_in2.link().voltage.upper() - output_lower),
current=self.pwr_out.link().current_drawn,
voltage_drop=voltage_drop,
reverse_recovery_time=reverse_recovery_time,
return self.pwr_ins.request("1")
elif item == "pwr_in2":
warnings.warn(
f"Use pwr_ins.request(...) instead.",
DeprecationWarning,
stacklevel=2,
)
)

self.assign(self.pwr_in1.current_draw, self.pwr_out.link().current_drawn)
self.assign(self.pwr_in2.current_draw, self.pwr_out.link().current_drawn)

self.connect(self.pwr_in1.net, self.diode1.anode)
self.connect(self.pwr_in2.net, self.diode2.anode)
self.connect(self.pwr_out.net, self.diode1.cathode, self.diode2.cathode)
return self.pwr_ins.request("2")
Comment on lines +57 to +59
@override
def generate(self) -> None:
super().generate()
@ducky64 ducky64 merged commit b690c01 into master May 20, 2026
12 checks passed
@ducky64 ducky64 deleted the diode-fix branch May 20, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants