## How to export C code generated by the CodeGenerati...

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

## Double Pendulum Linearization...

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

where:

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.

## Possible incorrect results when modeling a telescopic...

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

## Error, `MapleSim` does not evaluate to a module...

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?

## Initialization diagnostics questions...

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?

## MB parameter exports: How to prevent conversion to...

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

## Why does importing a MATLAB struct into MapleSim u...

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];
>> 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));

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!

## Searching the help system: Why are there no hits f...

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.

## Who invented the inverse model approach?...

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?

## Suggestions to improve the user experience of...

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.

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

## How do I implement the convolution integral of 2 c...

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:

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

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

## How do I implement expandable connectors from Mode...

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.

## how to get an adjustable parameter...

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