C_R

3542 Reputation

21 Badges

6 years, 73 days

MaplePrimes Activity


These are questions asked by C_R

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

(from https://www.youtube.com/watch?v=uaQh_bXcIGA)

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

Example: Assume expressions assigned to names

xa, xb, xc := y = x, y = x^2, x = x^3

y = x, y = x^2, x = x^3

(1)

where you want to apply a command (rhs in this example) to all names fitting to a certain scheme (here a and c)

seq(cat(x, i), i = [a, c])

xa, xc

(2)

`~`[rhs]([xa, xc])[]

x, x^3

(3)

Combining (2) and (3) in one line

seq(rhs(cat(x, i)), i = [a, c])

Error, invalid input: rhs received xa, which is not valid for its 1st argument, expr

 

throws an error. Although xa evaluates to an equation

rhs(xa)

x

(4)

and

whattype(cat(x, a))

`=`

(5)

seems to do the same.
I have not worked out what the xa is that rhs is receiving in the one line statement (see error).
Since rhs returns xa it does not look like a delayed evaluation.

 

Besides an explanation of what is going on, I'm interested if there is a way to debug what is passed to rhs?

Download cat_in_nested_statement.mw

t is removed from gamma(t)

sqrt(1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)

(1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2)

(1)

simplify((1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2))

(cos(alpha(t))^2*cos(gamma)^2-cos(gamma)^2+1)^(1/2)

(2)

lprint((1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2))

(1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2)

 

subs(gamma(t) = gamma(t), (1+(cos(alpha(t))^2-1)*cos(gamma(t))^2)^(1/2))

(1+(cos(alpha(t))^2-1)*cos(`γ`(t))^2)^(1/2)

(3)

simplify((1+(cos(alpha(t))^2-1)*cos(`γ`(t))^2)^(1/2))

(cos(`γ`(t))^2*cos(alpha(t))^2-cos(`γ`(t))^2+1)^(1/2)

(4)

lprint((1+(cos(alpha(t))^2-1)*cos(`γ`(t))^2)^(1/2))

(1+(cos(alpha(t))^2-1)*cos(`γ`(t))^2)^(1/2)

 

NULL

Download arg_removed.mw

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?

How can I achieve something like this (i.e. an output in a worksheet)?

It is important that the variables of the lables match the columns.

In the attached file is a typical dataset. A display of row lables would be optional.

Context: Easier interpretation (of the structure) of a Jacobian and subsequent manual solving the equations of interest that correspond to the rows.

 

Labels_for_sparse.mw

First 37 38 39 40 41 42 43 Page 39 of 46