Message Boards Message Boards

0
|
10615 Views
|
10 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

WSMModelData Failed to convert equations

I have a working WSM model that I can run with WSMLink. I'm trying to get a list of variables using WSMModelData[myModel,"AlgebraicVariables"], but I'm getting the error "Failed to convert equations". Can someone help me with this?

Assuming I get that working, can I get specific variables from specified components e.g. WSMModelData[myModel,{"AlgebraicVariables",myComponents}]

Thanks, Eric

POSTED BY: Eric Smith
10 Replies
Posted 9 years ago

Eric, two answers.

The short answer: run

equation

and after that you can see the algebraic variables and system equations.

The slightly longer answer: When you run a simulation with WSMLink (WSMSimulate["model"]) the model is translated by SystemModeler into the binary and that's what you run, the simulation results are then read back into Mathematica. You will always get the same results as running a simulation in SystemModeler Simulation Center. When you run WSMModelData["model"] WSMLink will convert the Modelica equations into Wolfram Language. Process for simulation and data

There are some constructs in Modelica that there are no representations for in the Wolfram Language, so it will not always be possible to fully translate everything.

POSTED BY: Johan Rhodin

Thanks Johan,

I assumed the Wolfram Language was just parsing the Modelica code but it must be more customized than that. I'll use your expression to look at the variables.

Eric

POSTED BY: Eric Smith

Hi again Eric!

When I try and validate your model in SystemModeler it tells me that it is structurally singular, maybe that's whats causing your problems?

[6] 22:48 Validation of model EricsTraining.SplitJunction
Error: [:0:0-0:0] Error: Model is structurally singular, the equations
volumeFlow.constantVolumeFlow = 0.0;
do not allow to solve for required variables.
POSTED BY: Patrik Ekenberg

volumeFlow.constantVolumeFlow shouldn't be one of the parameters. I apologize; I must have sent an old file. I've attached my latest package and it's running with WSMLink. Would you mind trying again?

Attachments:
POSTED BY: Eric Smith

Hi!

I now see the problem you are having. This seems to be an issue in WSMLink with the Thermal.FluidHeatFlow library that you are using in your model, where something is not currently supported. I've been told that this is something that will be addressed in an upcoming version.

POSTED BY: Patrik Ekenberg

That's disappointing and a bit perplexing since I thought SystemModeler worked off the same principles regardless of the domain. I'll check with Johan to see if this is caused by the "material" component or something else. The larger question becomes, if I start making custom components, what's required for them to be supported in WSMLink; what interfaces need to built in addition to the component.

Thanks for the response.

POSTED BY: Eric Smith

It should work regardless of domain. Unfortunately there was a bug in WSMLink (the Mathematica package for SystemModeler) that slipped into the release.

It has been fixed and should work in the next version.

POSTED BY: Malte Lenz

I see. Thanks for that information. Hopefully we get a minor release (bug-fix release) before too long.

POSTED BY: Eric Smith

Hi Eric!

Is it a specific model that is giving you that error message, or all models? Could provide it as an attachment to your question or something that gives the same error?

Yes, you should be able to extract algebraic values from specific components.

Needs["WSMLink`"]
WSMModelData["Modelica.Mechanics.Translational.Examples.Damper", "AlgebraicVariables"]

Gives a list of algebraic variables from all components:

all algebraic variables

From the documentation:

For variable and parameter lists, WSMModelData["mmodel",{prop,patt}] returns the elements of prop whose Modelica form match the string pattern patt.

You could use the pattern "componentName"~~__ (with '__' matching one or more characters):

WSMModelData["Modelica.Mechanics.Translational.Examples.Damper", {"AlgebraicVariables", "damper1"~~__}]

damper1 algerbraic variables

Or for a list of components:

WSMModelData["Modelica.Mechanics.Translational.Examples.Damper",  {"AlgebraicVariables", #~~__}] &
 /@ {"damper1", "damper2", "mass1"}

algerbraic variables from component list

Hope that helps!

Attachments:
POSTED BY: Patrik Ekenberg

Thanks for the response Patrik. I've attached the Package "EricsTraining" (a test package while I learn the ins and outs of WSM). The model "SplitJunction" is giving me trouble. The damper model you referenced reports the variables fine.

Thanks also for the details of how to do pattern matching for specific component variables.

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

Group Abstract Group Abstract