FOREACH component DO
FOREACH equation DO
COUNT number_of_variables IN equation
IF number_of_variables EQUALS 0 THEN
GENERATE ERROR MESSAGE
ELSE IF number_of_variables EQUALS 1 THEN
IF variable IS IN list_of_variables THEN
SYSTEM IS OVERCONSTRAINED
ELSE
variable IS A CONSTANT
ADD variable TO list_of_variables
IF (equation IS OF FORM "x = ..." WITH RHS NOT INVOLVING x)
OR (equation IS OF FORM "... = x" WITH LHS NOT INVOLVING x) THEN
equation FOR x CAN BE SOLVED
ELSE
equation FOR x CANNOT BE SOLVED DIRECTLY, BUT CAN BE SOLVED USING A SOLVER LIKE KINSOL
# resid = LHS-RHS
# IF variable HAS INITIAL VALUE THEN USE IT WITH KINSOL
ENDIF
ENDIF
ELSE
unknown_variables = []
FOREACH variable IN equation DO
IF variable IS NOT IN list_of_variables THEN
unknown_variables += variable
ENDIF
ENDFOREACH
IF LEN(unknown_variables) EQUALS 1 THEN
list_of_variables += unknown_variables[0]
equation CAN BE SOLVED # TO BE FINISHED
ELSE
# n = LEN(unknown_variables)
# Check (most likely outside this loop) other equations to see
# whether we have n equations with n unknowns (kind of), e.g.
# x+y=3
# x*z = 5
# y+z = 7
ENDIF
# x + y = sin(z)
# y = 3+5
# z = 7
ENDIF
ENDFOREACH
ENDFOREACH
IFx is defined, has no equation to compute it BUT has an initial value of 3THENx is considered to be a constant AND we also generate a warning that x has been considered to be a constant although it should have had an equation of the form x=3 and NO intiial value.
IFx has an initial value of 3 and an ODE to compute xTHENx is considered to be a state variable.
IFx has an initial value of 3 and an algebraic equation to compute xTHENx is considered to be a state variable.
IFx has no initial value and an algebraic equation of the form x=3 or x=3+5THENx is considered to be a constant.
IFx has no initial value and an algebraic equation of the form x=y+3 with y a constant THENx is considered to be a computed constant.
x: 3
y: 5
z: 7
x+y = z
residual = x+y-z
x = 3
y = 5
z: 7
x+y = z
x = 3
y: 5
z: 7
x+y = z
residual = x+y-z
x = 3
y: not intiialised
z: not initialised
x+y = z
underconstrained
The analyser should analyse the model without taking into account whether a variable has an initial value. The initial value of a variable should only be taken into account once we have analysed all the equations, in case having an initial value may give us a sensible system.
THINKING IN PROGRESS...
x
is defined, has no equation to compute it BUT has an initial value of3
THENx
is considered to be a constant AND we also generate a warning thatx
has been considered to be a constant although it should have had an equation of the formx=3
and NO intiial value.x
has an initial value of3
and an ODE to computex
THENx
is considered to be a state variable.x
has an initial value of3
and an algebraic equation to computex
THENx
is considered to be a state variable.x
has no initial value and an algebraic equation of the formx=3
orx=3+5
THENx
is considered to be a constant.x
has no initial value and an algebraic equation of the formx=y+3
withy
a constant THENx
is considered to be a computed constant.x: 3 y: 5 z: 7 x+y = z
residual = x+y-z
x = 3 y = 5 z: 7 x+y = z
x = 3 y: 5 z: 7 x+y = z
residual = x+y-z
x = 3 y: not intiialised z: not initialised x+y = z
underconstrained
The analyser should analyse the model without taking into account whether a variable has an initial value. The initial value of a variable should only be taken into account once we have analysed all the equations, in case having an initial value may give us a sensible system.