SciML / SciML/ModelingToolkitStandardLibrary.jl
Change of parameters from defaults are possibly ignored
@YingboMa is already working on this.
Since Nov 15, 2021.
- Dominant language
- Julia
- Stars
- 171
- Forks
- 49
- Avg merge
- 15h 50m
- Merged PRs (30d)
- 10
Description
I'm looking at the sources here
https://github.com/SciML/ModelingToolkitStandardLibrary.jl/blob/986436310582194c78d3200326e34bc770b2c2bb/src/Electrical/Analog/sources.jl#L63
and it looks to me like a signal is created using the numerical values of the input arguments, not the symbolic parameters. If the user tries to change the default parameter values when simulating, the change will be ignored.
I believe the correct approach would be to create the parameters with the numeric values as defaults, e.g.,
@parameters starttime=st
etc., and then use the parameter starttime rather than the numeric value st when creating the signal _step(t, δ, 1.0, st)
Here's an example
julia> volt
Model volt with 3 equations
States (5):
v(t)
p₊v(t) [defaults to 1.0]
p₊i(t) [defaults to 1.0]
n₊v(t) [defaults to 1.0]
n₊i(t) [defaults to 1.0]
Parameters (6):
offset [defaults to 0.0]
amplitude [defaults to 1.0]
frequency [defaults to 1.0]
starttime [defaults to 0.0]
phase [defaults to 0.0]
damping_coef [defaults to 0.0]
julia> equations(volt)
3-element Vector{Equation}:
v(t) ~ p₊v(t) - n₊v(t)
v(t) ~ ModelingToolkitStandardLibrary.Electrical._damped_sine_wave(t, 1.0, 1.0, 0.0, 0.0, 0.0)*ModelingToolkitStandardLibrary.Electrical._step(t, 0.0001, 1.0, 0.0) + ModelingToolkitStandardLibrary.Electrical._step(t, 0.0001, 0.0, 0.0)
0 ~ n₊i(t) + p₊i(t)
the equations do not contain the parameters, only numerical values
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.