From 88077dd0479ab5ea6f1ab9f79e90d6434a0b2c59 Mon Sep 17 00:00:00 2001 From: Jaakko Ruohio Date: Mon, 11 Nov 2024 19:17:43 +0200 Subject: [PATCH 1/2] Add capacitor initial voltage to README.md example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unless initial condition for capacitor initial voltage is given, `ODEProblem` errors ``` ┌ Warning: Initialization system is underdetermined. 0 equations for 1 unknowns. Initialization will default to using least squares. To suppress this warning pass warninitializedetermined = false. To make this │ warning into an error, pass fully_determined = true └ @ ModelingToolkit C:\Users\jaakkor2\.julia\packages\ModelingToolkit\zfOUk\src\systems\diffeqs\abstractodesystem.jl:1294 ┌ Warning: Did not converge after maxiters = 0 substitutions. Either there is a cycle in the rules or maxiters needs to be higher. └ @ Symbolics C:\Users\jaakkor2\.julia\packages\Symbolics\8MbnV\src\variable.jl:546 ERROR: Found symbolic value -capacitor₊p₊v(t) for variable resistor₊p₊i(t). You may be missing an initial condition or have cyclic initial conditions. If this is intended, pass `symbolic_u0 = true`. In case the initial conditions are not cyclic but require more substitutions to resolve, increase `substitution_limit`. To report cycles in initial conditions of unknowns/parameters, pass `warn_cyclic_dependency = true`. If the cycles are still not reported, you may need to pass a larger value for `circular_dependency_max_cycle_length` or `circular_dependency_max_cycles`. ``` Initial condition `v=0.0` is given here https://github.com/SciML/ModelingToolkitStandardLibrary.jl/blob/v2.17.0/docs/src/tutorials/rc_circuit.md#L23 and here https://github.com/SciML/ModelingToolkitStandardLibrary.jl/blob/v2.17.0/test/Electrical/analog.jl#L91 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb535fe38..839b022e2 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ V = 1.0 @variables t systems = @named begin resistor = Resistor(R = R) - capacitor = Capacitor(C = C) + capacitor = Capacitor(C = C, v = 0.0) source = Voltage() constant = Constant(k = V) ground = Ground() From 362b13721d3c38f1eb54ce2f963ef51332363f37 Mon Sep 17 00:00:00 2001 From: Jaakko Ruohio Date: Mon, 11 Nov 2024 19:30:46 +0200 Subject: [PATCH 2/2] modernize definition of t --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 839b022e2..917f29094 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,11 @@ The following is the [RC Circuit Demonstration](https://docs.sciml.ai/ModelingTo using ModelingToolkit, OrdinaryDiffEq, Plots using ModelingToolkitStandardLibrary.Electrical using ModelingToolkitStandardLibrary.Blocks: Constant +using ModelingToolkit: t_nounits as t R = 1.0 C = 1.0 V = 1.0 -@variables t systems = @named begin resistor = Resistor(R = R) capacitor = Capacitor(C = C, v = 0.0)