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}]
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.
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.
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.
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?
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.
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.
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.
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.
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.
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.