Group Abstract Group Abstract

Message Boards Message Boards

Interpret results of Extracting System Equations in SystemModeler?

Posted 9 years ago

Hi, When extracting System Equations using : WSMModelData["tempB1", "SystemEquations", t], my result is difficult to interpret, and there appears to be more equations than necesssary (way more ;-)

1) Is there any way to extract a condensed set of system equations ? 2) Is there a guide on interpreting the nomenclature of the equations (significance of special characters) ?

Please see attached System Modeler file and images.

Kind Regards,

John

Attachments:
POSTED BY: john massucci
6 Replies

For SystemModeler I'd recommend reading through the product documentation, available both in-product and on http://reference.wolfram.com/system-modeler/

For Mathematica, I think this question on the Mathematica StackExchange site has a fantastic set of links to both get started and learn Mathematica/Wolfram Language in-depth: http://mathematica.stackexchange.com/questions/18/where-can-i-find-examples-of-good-mathematica-programming-practice

That StackExchange site in general is a great place to learn Mathematica.

POSTED BY: Malte Lenz
Attachments:
POSTED BY: Neil Singer
Posted 9 years ago

Malte,

One last request (if possible) could you give me some pointers with regards to plotting specific state responses. I have copied the use of "%" in my plot command, and not sure how that is working w.r.t the state space matrix. Please see attached.

Could I thank you again for that very impressive first response ;-)

Kind regards,

John

Attachments:
POSTED BY: john massucci
Posted 9 years ago

Malte,

Could you recommend a good book on SystemModeler ? Your best three books on Mathematica ? ;-)

Kind regards,

John

POSTED BY: john massucci
Posted 9 years ago

Many thanks Malte !!

POSTED BY: john massucci

Let's start with the naming of symbols. To keep the hierarchy information from the model intact in the equations in Mathematica, a few special symbols are used:

  • "up pointer" that looks like a small triangle, which replaces the "." notation in Modelica
  • "underbracket" that looks similar to an underscore, which replaces the "_" in Modelica symbol names

There are a few ways to get a more condensed set of equations.

The most obvious one is to insert the numerical values of all parameters:

eqs = WSMModelData["temp_B_1", "SystemEquations", t];
pars = WSMModelData["temp_B_1", "ParameterValues"];
neqs = eqs //. pars

Which will eliminate all the parameters: Eliminated parameters

You can simplify knowing that the time variable will be larger than 0:

neqs2 = FullSimplify[neqs, t >= 0]

time>0

To do further processing we have to filter out the equations handling events:

{events, otherEqs} = {Select[neqs2, ! FreeQ[#, WhenEvent | If] &], 
  Select[neqs2, FreeQ[#, WhenEvent | If] &]} 

Then we can run Eliminate to eliminate variables we are not interested in. Here is an example where I have chosen to eliminate some internal variables from the equation system:

sotherEqs = 
 Eliminate[
  otherEqs, {m2\[UpPointer]flange\[UnderBracket]b\[UpPointer]s[t], 
   m1\[UpPointer]flange\[UnderBracket]a\[UpPointer]s[t], 
   m1\[UpPointer]flange\[UnderBracket]b\[UpPointer]f[t], 
   m2\[UpPointer]flange\[UnderBracket]a\[UpPointer]s[t], 
   k1\[UpPointer]s\[UnderBracket]rel[t]}]

simplified equations

To make things more easily readable, it may help to show equations in a column:

List @@ sotherEqs // Column

column of equations

Please note the warning that you received on the first evaluation of WSMModelData about algorithms. In this case, there is an initial algorithm in the pulse component that is not represented in the equations in Mathematica.

POSTED BY: Malte Lenz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard