How is the System constructor meant to be used❓
I have looked into the System docstring:
using ModelingToolkit
?System
It seems like the new structure is as follows:
where a number of kwargs are listed, and name is a required kwarg. Also, there are specialized structures (multiple dispatch, I assume), e.g.
System(eqs, iv, dvs, ps; kwargs)
In addition to the listed kwargs, the docstring states that field names can be used as keywords, e.g., unknowns and ps.
Question 1: I have tried both of the above constructor signatures. The second one (System(eqs,t,vars,params; name=name)) works, but I couldn't get the first one (System(eqs,t; name=name, unknowns=vars, ps=params)) to work.
Question 2: Is the recommended/"future proof" syntax the one with 2 positional arguments + kwargs? Or the one with 4 positional arguments (assuming DAEs).
Question 3: I have also tried to initialize a "state" (differential variable) with a symbolic expression...
# I have already defined rho and A in a @parameters block...
#Attempt 1
@variables m(t)=1.5*rho*A
# Attempt 2
System(eqs,t,vars,params;name=name, initialization_eqs=[m ~ 1.5*rho*A])
# Attempt 3
System(eqs,t,vars,params;name=name, initial_conditions=[m => 1.5*rho*A])
Attempts 1 & 2 kind of work if I do not specify values in the ODEProblem. However, they both fail with an error message of over-specification if I try to change the initial value of m in the ODEProblem.
Attempt 3, however, works.
... Does this imply that initial_conditions is the keyword to use for specifying initial values of variables? There is also a field guesses... is there any advantage in specifying guesses in the System constructor, instead of as metadata in the @variables begin...end block?
How is the
Systemconstructor meant to be used❓I have looked into the
Systemdocstring:It seems like the new structure is as follows:
where a number of
kwargsare listed, andnameis a required kwarg. Also, there are specialized structures (multiple dispatch, I assume), e.g.In addition to the listed kwargs, the docstring states that field names can be used as keywords, e.g.,
unknownsandps.Question 1: I have tried both of the above constructor signatures. The second one (
System(eqs,t,vars,params; name=name)) works, but I couldn't get the first one (System(eqs,t; name=name, unknowns=vars, ps=params)) to work.Question 2: Is the recommended/"future proof" syntax the one with 2 positional arguments + kwargs? Or the one with 4 positional arguments (assuming DAEs).
Question 3: I have also tried to initialize a "state" (differential variable) with a symbolic expression...
Attempts 1 & 2 kind of work if I do not specify values in the
ODEProblem. However, they both fail with an error message of over-specification if I try to change the initial value of m in the ODEProblem.Attempt 3, however, works.
... Does this imply that
initial_conditionsis the keyword to use for specifying initial values of variables? There is also a fieldguesses... is there any advantage in specifyingguessesin theSystemconstructor, instead of as metadata in the @variables begin...end block?