MapleSim Questions and Posts

These are Posts and Questions associated with the product, MapleSim

 

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.

Prismatic_Joint_with_Elasto_Gap.msim

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?

Initialisation_diagnostics_error.msim

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).

Init_diagnostics_ignore_listed_as_guess.msim

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")?

MB_exports_with_rational_quotients_instead_of_symbols.msim

 

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!

The Examples section on the help page of a command is important for learning, but cannot cover all uses. This is especially true for general purpose commands like "solve" or "simplify". Searching all help pages that contain the word "solve" results in too many irrelevant hits that do not contain examples.

Why does adding a bracket to a command not filter for help pages with examples using the command?

Inside a help page Find/Replace finds such strings.

Inverse kinematics can be done in several ways (this webinar gives a very good overview https://www.youtube.com/watch?v=X0OZ9EM6dns). A effective and simple method is to run a model in reverse direction. This can’t be done with causal modeling tools, where information flow is fixed by design (https://de.maplesoft.com/support/help/MapleSim/view.aspx?path=MapleSimUserGuide/Chapter01).

Inverse kinematics, which is possible with acausal modeling tools, is only an example for running a model in the reverse (i.e., inverted) direction.

Without success, I tried to find a reference who first came up with that elegant approach.

Anyone knows more?

MapleSim is a mature product. The rich component library leaves little room for improvement for wide range of applications. It is understandable that latest product releases focused on specialized toolboxes and performance improvements.

Here is what I think could be beneficial for many users, which is not related to performance, but can help improve the user experience:

  1. Crossing connection lines: A view option to render a crossing connection line with an arc at the crossing point of two connection lines of the same type. Right-click on a connection line might be enough.
     

    -> To avoid misinterpretations of routing in crowded model diagrams
     
  2. Parameters: An option to populate or reset changes in the parameter pane to the parameter default settings view and vice versa

    -> When testing or optimizing a model, sometimes changed parameters should become default values or be reset. Doing this manually is error prone and takes time.
     
  3. Component flip: Selecting more than one component including connection lines and applying a flip to all of them

    -> When building a model, it can happen that a nicely laid out arrangement of components needs to be mirrored or rotated in its entirety. Doing this component by component and connection by connection is a lot of work that can be saved by this option.
     
  4. Initial conditions: An option in the view menu to highlight components where ICs have been changed from ignore to treat as guess or to strictly enforce
     

    -> ICs are set for many purposes. In addition to defining ICs needed for simulations, this can include extracting equations, testing different model states, or temporarily "immobilizing" a model during assembly, to name a few. Undoing a tentative change can easily be forgotten. Combining existing models that work on their own into a new more complex model often results in an overly constrained model that either cannot be assembled or does not simulate.
    In debugging a model, ICs of all components must be individually inspected. This takes time. A quick overview that shows components where ICs are not set to ignore would be very helpful in debugging models.
     
  5. Undo Create subsystem: A reverse operation that inserts the contents of a subsystem into a parent subsystem.

    -> With the evolution of a model it is sometimes useful to exclude or include existing components from or to a subsystem. For this purpose, an undo create subsystem operation should preserve existing connections. A time saver.
     
  6. Subsystem ports: An option to align a subsystem port to the drawing grid to remove “micro” steps in connection lines
     

    -> For perfectionists who do not have the time to learn (and remember) how to fine-tune at the component level

    Update: MapleSim 2022.2 has subtantially improved on this. This item could be removed from the list.
     
  7. A history or log function of user actions changing a model, its parametrization or internal state.

    -> Often a model does not simulate at all or as desired after modifications. Restoring to a configuration that worked by undo only goes back to the last simulation performed. In such a situation, only reloading the latest file version and redoing modifications may restore the desired model, parametrization, or state. This takes time and migth be unsuccessful. A record of user actions would be a great help.
    History or log information in file format could also help MapleSim support to reproduce an error.

For me personally, reducing errors (4. > 7. > 2.) would improve the use experience much more than layouting aids (3. > 1., 5., 6.).

Hi there!

I'm attempting to develop a custom library in MapleSim (a Modelica solver engine) that can use convolution integrals to model the hydrodynamic behaviour of floating bodies. The convolution integral is mathematically represented as follows:

a general form of a convolution integral, spanning from negative to positive infinity in time

And the equation I'm particularly interested in solving is as follows:

Cummins equation to determine the motion of a floating body in waves

I'm trying to solve this convolution integral in Modelica using a model that can be imported to MapleSim. So far, I've had no luck in implementing this convolution for continuous functions symbolically. I have used a numerical approach on 2 arrays using the following approach in Modelica:

// Modelica function
function convIntegral
  input Real simTime;  // Simulation time
  input Real f[:];     // Kernel function array
  input Real g[:];     // Second function array

  output Real h[(2*simTime) - 1];    // Output the convolution integral in the form of an array
  
  // Define the algorithm to numerically compute the convolution integral of 2 arrays
  algorithm
    // Initialize the output array with zeroes
    for i in 1:((2*simTime) - 1) loop
      h[i] := 0;
    end for;
    
    // Iterate over the simulation time
    // Recursively increment the convolution array with the pointwise product of the 2 functions
    for i in 1:simTime loop
      for j in 1:simTime loop
        h[i+j-1] := (f[i] * g[j]) + h[i+j-1];
      end for;
    end for;
end convIntegral;
// End of function to compute the convolution integral

This works perfectly for discrete samples and I have verified it with output from Matlab's inbuilt function

conv(A,B)  % For 2 arrays A and B

However, I would like to implement this on 2 continuous functions and this numerical approach does not work since MapleSim does not support conversion between discrete and continuous signals.

I understand that convolution is essentially an operation between two functions, where we time-flip one of the functions (kernel) and then slide it across the other function while measuring the bounded area and outputting that as the result of the convolution. I include this image from Wikipedia that sums up convolution: (Not including links as they mark questions as spam)

I've tried implementing this in Modelica using the following code:

// Model to perform convolution on 2 continuous functions
model ConvolutionalIntegral

  extends Modelica.Blocks.Icons.Block;

  // Define model variables
  Real kernelFunction = (e ^ (-0.5 * time)) * cos(0.5 * time);  // I've taken an example of a function I might use
  Real kernelFunctionFlipped = (e ^ (-0.5 * (T_sim - time))) * cos(0.5 * (T_sim - time));  // I've flipped the kernel function about the vertical axis by converting the (time) variable to (T_sim - time) where (T_sim) is a variable storing the simulation duration
  Real secondFunction;  // The other function for the convolution
  Real convolutionIntegralOutput;  // Function to store the output
  
  equation
    // Convolution implementation
    der(convolutionIntegralOutput) = kernelFunctionFlipped * secondFunction;

    // Final equation to solve
    der(secondFunction) + convolutionIntegralOutput = 0;
    // An example of a differential equation I'd like to solve involving the convolution integral
    
end ConvolutionIntegral;

I had hoped that this would yield the output of the convolution since I'm essentially multiplying the time-flipped kernel and the other function and then integrating them over time. However, the output does not provide the expected result and it appears that Modelica interprets my code to mean that I'm integrating the pointwise product of these 2 functions over time instead of sliding the kernel over the other function.

I'd appreciate it if you could take a look at my code and my approach to solving the convolution integral symbolically, and point out where I'm making a mistake and what a possible fix might be.

Thank you!

We are happy to announce that we released MapleSim 2022 today.

The MapleSim 2022 family of products offers improvements in modeling and connectivity, including many that are in direct response to customer requests. Improvements include:

  • Reduce diagram clutter by using “wireless” To-From blocks for a larger variety of signals
  • Easily create, customize, and fine-tune control valves with new components and tools in the hydraulics library
  • Expand modeling scope with improvements to several specialized libraries and toolboxes, including the MapleSim add-on products for Battery, Heat Transfer, and Web Handling
  • New productivity and connectivity features in MapleSim Insight,  a standalone product in the MapleSim family that gives machine builders powerful simulation-based debugging and 3-D visualization capabilities that connect directly to your automation tools

 

See What’s New in MapleSim 2022 for more information about these and other improvements.

Hi there!

I'm working on implementing a custom Modelica Library in MapleSim 2021. I have Maple 2021 installed and my software is up to date. The library I have developed is in a single file (extension ".mo") which I developed on an IDE for Modelica i.e., I did not create the library using MapleSim. During the import into MapleSim, no errors appear in the system logs. All my components and models have been imported except for an "expandable connector". It appears that the problem is with the term "expandable".

Since this expandable connector does not appear among my library components, I attempted to create a custom component using the Modelica code editor in MapleSim. However, the file cannot be saved while I prefix the term "expandable" to "connector". The software allows me to save the file with the new code after dropping the "expandable" term.

I know that expandable connectors are used by Modelica. Here are the references I used during development:

https://mbe.modelica.university/components/architectures/expandable/

Working with Expandable Connectors - Claytex

However, there does not seem to be any information on expandable connectors in MapleSim. I'd appreciate it if any of you could throw some light on why I'm not able to import this component into MapleSim and fixes/suggestions on what I might be doing wrong. If any further information on my question is required, please do let me know.

example.msim

I want to get an adjustable parameter in maplesim. For example, here is a pulse voltage source, i  want to make its amplitude controlled by another voltage output (doesn't exist in this .msim).

ac-dc-dc1.msim

When i click off the "Plot events", the figure of Probe2 is pretty different comparing with "Plot events" is turned on. Here is my assumption: the simulation duration is 500 seconds and the plot points are 2000. Considering the frequency of sine current is 40HZ, many points cannot be ploted in the figure. So it is not a big deal for curve like Probe1 and Probe5 because  they tend to be a constant and Probe2 just reflect the tendency.

MapleSim is a fantastic tool to model multi-domain physical systems at a level that was unthinkable not so long ago. This post is about a simple problem that can be solved by hand, but where I failed with MapleSim using online resources.

For some time, I have been looking for answers to two questions:

  • How to control which variables (and parameters) are included in MapleSims equation exports? This question is crucial to derive forward and inverse kinematics.
  • Can the Equation Extraction App (in principle) provide a similar set of equations than the Multibody Analysis App? This question is rather academic until multidomain exports are desired (which the Multibody Analysis can’t provide).

The attached model helped me to clarify a few things and discover a real hidden secret (at least it was for me). I hope it can help others.

The model is a rather simple 3DOF mechanism. The task was to get a set of equations to derive the two rotations and the one displacement of the mechanism as a function of x,y,z coordinates.

After watching videos and inspecting models from the model gallery on inverse kinematics, I placed motion drivers for the input variables, added sensors for the output variables and wrapped the mechanism into a subsystem. However, as explained in more detail in the attachment, the set of exported variables was incomplete in both apps (AEs exports in the Equation Extraction Export and Position Constraints in the Multibody Analysis Export). Furthermore, the number of extracted equations did not match the three degrees of freedom.

After numerous trials it turned out that in addition to the motion drivers and sensors, initial conditions (ICs) had to be set. This is the hidden secret.  The crucial initial conditions (detailed in the attachment) are not required to assemble and run the model. So, introducing them temporarily for equation extraction is not obvious and never came to my mind. Setting ICs is, if I am not completely mistaken, also not highlighted in the documentation. This little trick of additionally setting initial conditions answered the above questions positively (at least for this 3DOF mechanism). In fact, it worked so well that all other failed attempts of conditioning the model for equations extraction worked immediately:

  • Immobilizing the assembly with a Fixed Frame (using parameters for the fixed frame position to represent input variables; the fixed frame can be inside or outside the subsystem model).
  • Using one Prescribed Translation component Instead of 3 motion drivers
  • Using variables to pass motion signals into the model subsystem instead of using signals and ports (using From variable and To Variable components)

These attempts underline the effort and the time spend to get the relevant equations for that simple problem. As it turned out, all approaches work but are not even required for the mechanism. The key to success was setting the ICs of the joints.  One can even strip the model down to its skeleton (removing all motion drivers and sensors as in the screen shot bellow) and still get the desired simple set of equations, provided the ICs are set.

 

It has to be noted, that the mechanically coupled (highlighted in yellow) prismatic joints contributed to the problems: MapleSim does not seem to take this mechanical constraint into account (as I would have expected). The ICs of both coupled components must be set to get the three equations containing all desired in and output variables.

If my finding is correct and of general relevance, I like to suggest including such kind of tips and tricks in training or reference material.  From an application engineer or developers’ perspective, knowing the underlying algorithms, its probably obvious what has to be done. But from a user’s perspective MaplsSim is a black box that works magically well in most cases. If it does not, trial and error is often the only alternative to make it work, because models are either too complex or too confidential to be shared with others.   

What I am addressing here is only the initial step of getting the desired equations. There is more to master. Save manipulation of equations too big to be inspected visually is also important. This has been well covered in several videos. Unfortunately, the quality of some of the footage does not allow to capture details of Maple commands. If possible, such material should be updated or replaced.

Overall, a collection of tips&tricks and dos&don’ts could establish some kind of best practice in deriving kinematics. If others would share their experience and findings, we all could save allot of time. A collection of valuable posts, questions, models, videos, and webinars could be a start. This collection not necessarily has to meet the high Maple standards of mathematical exactness and consistency. Engineers also accept pragmatic solutions to solve a problem.

If my findings are incorrect or you have better advise, please let us know.

MBA_and_equation_extraction.msim

piezoelectric_equivalent_with_ac-dc_(1).msim

I try to build a piezoelectric equivalent circuit (a sine current source, a capacitor and a resistor), but it doesn't act as a voltage source. I also try to change the forward voltage of the ideal diode in full-bridge rectifier and find that the output voltage of piezoelectric equivalent circuit cannot exceed forward voltage.

By the way, the parameters of piezoelectric equivalent circuit are well set according to a paper.

Could you give me some advice?

2 3 4 5 6 7 8 Last Page 4 of 41