Add Chua circuit examples, alpha-transform dynamics, and core WDF extensions#5
Add Chua circuit examples, alpha-transform dynamics, and core WDF extensions#5frantic0 wants to merge 15 commits intogusanthon:mainfrom
Conversation
… circuit impedance/conductance calculation
|
Hi @frantic0 Thanks a lot for your contribution. Unfortunately, I am very busy these days. Hopefully we can give you some feedback soon. |
|
Thanks so much for the reply @xaviliz, and no worries at all, I completely understand how busy the end of a course can be (it’s a hectic time on my side too!). I really appreciate you taking the time to look at this. I also wanted to say how much I enjoy pywdf, it’s a fantastic project and a great resource for exploring WDFs in practice. Happy to make any changes or adjustments once you’ve had a chance to review. |
|
Hey @frantic0 , thanks so much for the contribution this is great work! Just added a few minor comments but otherwise looks great! |
|
Hi @gusanthon @xaviliz, I hope you’re both enjoying a good seasonal break. Just checking in on the state of the PR, I’m very happy to make any changes you’d like before it’s ready to merge. Do let me know, please. |
|
Hey @frantic0 , sorry for the late reply! I left a couple small comments in the review, after that I think it's ready to merge. Thanks again for the contribution! |
|
Hi @gusanthon thanks, glad that the contribution was found valuable. I can't seem to find any review or comments... Am I missing something? |
pywdf/examples/inductor.py
Outdated
| # self.SW1 = Switch(self.S1) | ||
|
|
||
| # init and set circuit | ||
| super().__init__(self.Vs, self.S1, self.C1) |
There was a problem hiding this comment.
I think this should be L1 instead of C1?
There was a problem hiding this comment.
correct inductor variable in constructor argument
pywdf/examples/resistor_parallel.py
Outdated
| self.R2.set_resistance(new_R) | ||
|
|
||
|
|
||
| def process_sample(self, sample: float) -> float: |
There was a problem hiding this comment.
I'm getting a ValueError running this, not sure we need to override process_sample here?
There was a problem hiding this comment.
correct, we don't need it. I removed it and fixed the problem
pywdf/examples/voltage_divider.py
Outdated
| self.R2.set_resistance(new_R) | ||
|
|
||
|
|
||
| def process_sample(self, sample: float) -> float: |
There was a problem hiding this comment.
same ValueError here, don't think process_sample needs overriding
There was a problem hiding this comment.
same problem, we don't need it. I removed it and fixed the problem
pywdf/core/circuit.py
Outdated
|
|
||
|
|
||
|
|
||
| def process_sample_i_v(self, sample: float) -> float: |
There was a problem hiding this comment.
| def process_sample_i_v(self, sample: float) -> float: | |
| def process_sample_i_v(self, sample: float) -> tuple[float, float, float]: |
There was a problem hiding this comment.
correct type anotation to tuple of floats
|
Hi yes @frantic0 sorry about that, looks like I didnt submit the review. Hopefully you can see it now. Thansk again! |
correct return type annotation to tuple[float, float, float] Co-authored-by: gusanthon <99610799+gusanthon@users.noreply.github.com>
|
hi @gusanthon, thanks a lot for the review and suggestions! I’ve gone through and addressed all the comments in the latest commits. Please let me know if you’d like any further changes. |
| @@ -1,14 +1,25 @@ | |||
| from pywdf import RCA_MK2_SEF, TR_808_HatResonator, DiodeClipper | |||
| from pywdf import RCA_MK2_SEF, TR_808_HatResonator, DiodeClipper, VoltageDivider, Chua | |||
There was a problem hiding this comment.
test.py is failing, looks like Chua is not exported in __init__.py
also seems like the Chua constructor takes different args
There was a problem hiding this comment.
fixed Chua export in init.py and Chua constructor in test.py
| import math | ||
| import numpy as np | ||
|
|
||
| from pywdf.core.solver.newton_raphson import newton_raphson |
There was a problem hiding this comment.
test_newton_raphson.py fails - I don't see newton_rapshon in the solver module?
There was a problem hiding this comment.
Added a small sys.path bootstrap at the top of tests/test_newton_raphson.py and tests/runge_kutta.py to allow direct execution
pywdf/examples/inductor.py
Outdated
| if self.frequency != frequency: | ||
| self.frequency = frequency | ||
|
|
||
| self.L = 1.0 / (np.square(self.twopi * frequency) * self.C) |
There was a problem hiding this comment.
this is causing AttributeError: '_Inductor' object has no attribute 'C'
|
I'm also getting a path issue when plotting in each of I also noticed Thanks again for the updates! |
This pull request adds support for simulating the Chua circuit in
pywdfand introduces a small set of extensions to the core WDF API, along with new examples and documentation updates.Core API changes (
pywdf/core/wdf.py)ChuaDiode, a nonlinear negative-resistance element implementing a piecewise-linear I–V characteristic.SeriesVoltage, a two-port series adaptor with an embedded resistive voltage source for injecting voltage impulses (used to excite the Chua circuit, but reusable in other circuits).CapacitorandInductor), with parameters for selecting between bilinear (Tustin) and backward-Euler behaviour and exploring different stability/accuracy trade-offs.New examples
SeriesVoltageadaptor.resistor,resistor_series,resistor_parallel,inductor, andcapacitor.Documentation
README.mdto the Meerkötter & Scholz paper describing the digital simulation of nonlinear circuits by WDF principles.Testing