MapleSim Questions and Posts

These are Posts and Questions associated with the product, MapleSim

A failing slinky is another intriguing physics phenome that can be easily reproduced with MapleSim.

The bottom of a vertically suspended slinky does not move when the top is released until the slinky is fully collapsed.



To model this realistically in MapleSim, it is necessary to

  • Establish a stretched equilibrium state at the start of the fall
  • Avoid penetration of windings when windings collapse (i.e. get into contact)

The equilibrium state is achieved with the snapshot option. Penetration is avoided with the Elasto Gap component. Details can be found in the attached model.

A good overview of “Slinky research” is given here. The paper provides a continuous description of the collapse process (using an inhomogenous wave equation combined with contact modeling!!!) and introduces a finite time for the collapse of all windings. Results for a slinky are presented that collapses after 0.27s. The attached model has sufficient fidelity to collapse at the same time.

Real Slinkies also feature a torsional wave that precedes the compression wave and disturbs an ideal collapse. This can be seen on slowmo footage and advanced computer models. With a torsion spring constant at hand (are there formulas for coil springs?), it could also be modeled with MapleSim.


Maple offers the dimension “lenght” whereas MapleSim offers two types.

What is the difference between the two types length and distance?

Can they always be used interchangeably?


does the update of MapleSim 2022.2 have a bug when loading the own libraries? 
After installing the MapleSim 2022.2 update, my libraries have disappeared. I am unable to load them again. The libraries are still in the same folder as before, but when I try to load them, I get the error message

However, the library NoiseX is not listed in the left bar. Even when I try to create a new library, it is not shown in the left bar. On the other hand, there are no problems with the imported libraries. Many thanks in advance for any advice. 

Best wishes,


Anybody find Import CAD closes MapleSim 2022.2 when just opening file chooser when attempting to import CAD file?


We have just released the 2022.2 updates for Maple and MapleSim. These updates are freely available to all customers who have the 2022 version of these products.

Maple 2022.2 includes improvements to worksheet performance, the math engine, and more. As always, we recommend that all Maple 2022 users install this update. It is available through Tools>Check for Updates in Maple, and is also available from our website on the  Maple 2022.2 download page, where you can also find more details.

The MapleSim 2022.2 family of products offers an enhanced user experience through an expansion of the modeling libraries, a range of new productivity features, and several new options requested by users. See the MapleSim 2022.2 update page for details on new features, and for instruction on how to obtain your update.

Maple allows to extract, manipulate, and optimize equations from a MapleSim model. Code can be generated from the equations in various programming languages. To verify the code, C code can be imported back into the original MapleSim model and compared to the model.

This verification step is not an everyday task, but it is advisable before the code is used elsewhere (e.g., in a controller). This post summarizes helpfull links and provides an additional example with equations that are too large to be efficiently verified by code review.

Comparison to a physical model is demonstrated here on an older version of MapleSim (~2015). In newer versions the import has changed (basics are described in Tutorial 6.6: Using the External C Code/DLL Custom Component App). An external C compiler must be set-up to make the import work.

The attached MapleSim model verifies against an optimized custom component. Instead of manually entering and modifying the code as described in the Tutorial 6.6, the model uses a Maple worksheet that programmatically generates C code from Maple equations and modifies the C code (sets C definitions and parameters) to be usable for MapleSim’s External C/Library Block App.

The Maple worksheet to generate and modify C code has been improved in many details with support from MaplePrime users for which I would like to express my thanks.




I have polished up findings with custom components to share it here:

Optimized code generated with Maple’s codegen package cannot be used in the same way as it was possible with older versions of MapleSim’s Custom Component Template.

Intermediate variables `tx` (where x is an integer) of the optimized code are interpreted as physical parameters in the current template version and not as variables. This makes sense and is more consistent with MapleSim’s definition of variables and parameters, but leads to errors in MapleSim.

The attached model shows how optimized code can be generated for the current template and compares an older, still working (!) template with the new one.

The attached worksheet contains commands to programmatically generate optimized code for the current Custom Component Template.


To make the "Simple External Code Function" example of the tutorial work, an external complier is required.

in MapleSim:-CreateDataRecord) invalid input: dsolve/numeric/ToExternal:-AddTempFile expects its 1st argument, f, to be of type string, but received [[["f1", 1864151924736]]] (3.597s)


help(Setup, Compiler) in Maple 2022 provides a link to supported compilers, which are Visual Studio 2017 and 2019.

In the list of available downloads there is no mention of "Express Edition". Which of the packages can be installed alternatively?

A "while" ago this was possible by commands. E.g.:


I consulted the help pages for Export and CodeGeneration options, but could not find anything suitable to generate a C code file.

Did I overlook something or searched for the wrong help pages?

If such options no longer exist, what is the preferred way to transfer C code from Maple to MapleSim?

Am I supposed to copy, paste & save with a third party editor? If I do so for a C code generated from a Maple procedure (generated with makeproc), I get

A complete example that works in 2022 versions would be helpfull. The tutorial "6.6 Tutorial 6: Using the External C Code/DLL Custom Component App" unfortuneately does not include code generated by Maple that can be imported, compiled, simulated and verified against a MapleSim model as in the example from youtube (which is still very instructive by the way). 

I'm confused by the state equations resulting from linearizing the DoublePendulum example model.

The state equations are:

diff(x[1](t),t) = x[2](t),

diff(x[2](t),t) = 0,

diff(x[3](t),t) = x[4](t),

diff(x[4](t),t) = 0


x[1](t) = R1_theta(t),

x[2](t) = diff(R1_theta(t),t),

x[3](t) = R2_theta(t),

x[4](t) = diff(R2_theta(t),t)

Am I understanding correctly that the state equations say that the angular acceleration of both revolute joints is zero? This is clearly not the case when you simulate the model and view the plots for angular acceleration. Can someone explain to me what's going on? Model with worksheet attached.


Combing a Prismatic Joint component with an Elasto Gap component does not always provide correct results. Incorrectly combined (red mass below), a force is generated although the distance between the flanges is greater than the relaxed spring length. A force is exerted (instead of no force is exerted as stated here) on the mass which leads to a smaler deflection (expected are 9.81 m).

This happened to me although I connected flange_a to flange_a and flange_b to flange_b in configruation A bellow. Configuration B works with inverted flanges and configuration C works with inverted unit vector of the prismatic joint. By reversing the direction of gravity, configuration A becomes a valid configuration and configurations B and C become invalid configurations.

It seems that in invalid configruations the value of the  flange distance s_rel can have a large magnitude but is negative in sign which generates significant forces although there is no contact of flanges.

So far for the observations.


Would a change of the contact condition

prevent invalid configurations or do we have to live with it for principal reasons that I am over looking?

If so, I don't see a foolproof method to avoid invalid configurations. Instead, I can only suggest measuring the flange distance of the Elasto Gap component as in the attached. If negative values of large amplitude occur, the configuration is invalid.

Assuming that a beginner would connect intuetively flange_a to flange_a and flange_b to flange_b, there is a chance of 50% that the configuration is invalid (A instead of C). This is too much to be acceptable, especially since verifying results in complex assemblies is often not possible.

It is worth noting that the contact condition comes from the underlying Modelica component and not from MapleSoft.


I have maplesim installed and I get the error "Error, `MapleSim` does not evaluate to a module" when I run A:=MapleSim:-LinkModel(); in a Maple worksheet.

Does anyone know how to solve this error?

Q1: clicking on a variable in the attached I get

What does it mean and how can I fix that when it happens?


Q2: Why are initial conditions which are set to "Ignore" listed as "Guess"?

I intend to use the initialization diagnostics to filter a model for components that have initial conditions set. In the attached example (excerpt from a larger model), this does not work the way I want it to (i.e. I don't want P1 to be listed a guess).


Q3: The app seems to be a powerfull tool. Is it explained somewhere how to use the app to debug a model?

Multibody exports from MapleSim to Maple convert a symbolic expression to a rational quotient:

The parameters (parameter "a" above) disappear in the exported equations. How can I prevent this (conversion of sqrt3 and disapprence of "a")?



Hi there!

I have developed a component in Modelica to import values from a Matlab struct into MapleSim and use it with other components. This data is saved in a ".mat" file and the struct was constructed as follows:

% Matlab command window
% Struct name is "bemData" saved in a v7 format to be read in by Modelica
>> bemData.m33 = 100;
>> bemData.Ainf33 = 100;
>> bemData.Khs33 = 20000;
>> bemData.ss_rad33.A = [1 1;0 1];
>> bemData.ss_rad33.B = [1;0];
>> bemData.ss_rad33.C = [1 1];
>> bemData.ss_rad33.D = 0;
>> save -v7 bemData.mat

And the Modelica code I am using to try import this into MapleSim is as follows:

Modelica.SIunits.Mass M = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.m33",1,1));

Modelica.SIunits.Mass Ainf = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.Ainf33",1,1));

Modelica.SIunits.TranslationalSpringConstant C = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.Khs33",1,1));
Real A[2,2] = Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.A",2,2);

Real B[1,2] = transpose(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.B",2,1));

Real C[1,2] = Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.C",1,2);

Real D = scalar(Modelica.Utilities.Streams.readRealMatrix("bemData.mat","bemData.ss_rad33.D",1,1));

I then use these imported variables to solve ODEs, and the result is incorrect. I have narrowed it down to the fact that MapleSim/Modelica imports a value of 0 in place of the original data in the struct. Moreover, there is no way to attach a probe to any of the imported variables in MapleSim (I need to force all model variables to be displayed in the Simulation results tab).

I would appreciate help in pointing out where I might be making a mistake. My primary concern is why a value of 0 is being imported in place of the actual Matlab struct data. When I use Matlab's command window to check the contents of the struct, they appear to be in order.

Also, I have saved the struct file in the same folder in which my custom component is stored (the Modelica file where I have written the code to import the data). Should I be saving this file elsewhere?

Thank you!

1 2 3 4 5 6 7 Last Page 2 of 40