C_R

3427 Reputation

21 Badges

5 years, 326 days

MaplePrimes Activity


These are replies submitted by C_R

@Carl Love @nm @tomleslie

These are all excellent answers!

It's difficult to pick a winner.

nm answer uses commands that can be found in the help system.

That suffixed can be used as a command without "type" suprises. From the help system I can deduce at most a use like this

            select(X -> `if`(type(X, 'suffixed(t, integer)'), true, false), lst)

(I assume that Carls &under is required for other structures than sets.)

Thanks allot!!!

@Joe Riel @Thomas Richard 

Here is an update what I could figure out:

  • ExternalCCodeGen I was refering to is actually not an old Maple command as I assumed, but a procedure written by the author of the video. A call to CodeGeneration (to create a C code string) and to FileTools[Text][WriteFile] (to write the string to a file) could be used for a replacement of ExternalCCodeGen.
  • Much simpler to save is Thomas solution.
  • Saving is also possible with the External C/Library Block App and the option “Text Area”. In the text area: copy&paste Maple Output of C code -> optionally modify -> save file.

Using C code in MapleSim with the External C/Library Block App requires customizing the generated code to definitions (#define) and parameters accepted by the App. Knowledge of C is needed for that.

@chriskiwi 

I meant: You could upload screen shots that we can see how a small palette looks like.

I use a PC with monitors of different resolutions, which requires adjusting the scaling options. Maple in native 4K resolution works, but menus are just too small on a notebook (but a real joy on a large screen)

attached samples (green arrow for upload) are also helpfull.

@Joe Riel 

I did that (with the Custom Component App) before I generated the C code with the same list of equations.

That worked well and matched the kinematics of a MapleSim model.

Now I want to test (verify) C code with MapleSim before using it outside MapleSim. A test simliar to what is demonstrated here https://www.youtube.com/watch?v=uaQh_bXcIGA.

Let's see how far I get with the solution of Thomas. I will send an update.

@Thomas Richard 

In other words: string can be the value of output but if the value of output is a string its a filename.

I missed the two meanings of the string string in the paragraph of the help page. At least it is not obvious.

Thank you!

@tomleslie 

Now it makes sense.

The equation label (2) in my example labels an output (the return value xa,xc of cat). Referring in a subsequent statement to the same equation label evaluates the output to its value (which are equations). This explains why no eval is needed when two statements are used.

This also explains why no additional eval is needed in nested statements when an output or a return value is already evaluated, which is the case for most commands.

Thanks for the help in identifying this subtle difference.

@Carl Love 

Your answer provides an operator that returns an evaluated expression for the types of operands I have used. Comparing the help page of || to the answer of Tom makes the different levels of evaluation clear.

Thanks for this "discouraged" and unbeatable compact alternative!

@tomleslie 

This explains why rhs returns a name (unevaluated).

What I still do not understand in my example is why two separate statements (lines of input) do not need an eval. A which point is the eval happening? Maybe it’s because the “termination of a statement” (an input line) forces an evaluation.

Thank you!

@wmcnally 

The RLC circuit is a linear time-invariant system (LTI system). Linearization is independed of the linearization point which is not the case for the double pendulum

Newer MapleSim versions may provide a “foolproof” way.

In the attachment, the use of contact components instead of an elasto gap component shows no dependence on the sign of the axis of the prismatic joint for the case discussed.

Prismatic_Joint_with_Contact_Components.msim

@Joe Riel 

I overlooked the fact that my suggestion only makes sense for conventional compression springs.  It looks like we will have to live with the current implementation unless a better contact condition is proposed that can also handle an unstretched spring length s_rel0 of zero length or even of negative spring length. Some experts might find such length definition useful.

I am afraid that my main concern, of pointing out potential use errors of sign, is not well reflected in this post. Here is another attempt that hopefully better illustrates the consequences of an invalid configuration (red mass).

As indicated by the green mass, there should be no movement, but the red mass starts moving towards the contact point (at the x=0.1) because of an error of sign that is not obvious to avoid. It seems that the only way to deal with it is measuring s_rel and verifying the sign.

On a different case I was lucky enough to see that “something” was wrong with the results, but it took me considerable time to identify the cause. Unfortunately the text passage of the help page of the Elasto Gap component, that I consulted several times to make sure that I used the component correctly, is rather supporting the natural interpretation of a distance in terms of magnitude. I think a reminder of the importance of the sign would not harm (Or examples. The model gallery is full of it, but there is no way to filter for components used in a model.)

Thank you for your comment. I hope the discussion at least helps to draw attention to the fact that there can be errors of sign that are not obviously avoidable by either good practice or by component design.

Prismatic_Joint_wo_spring_with_Elasto_Gap.msim

@phil2  @Joe Riel 

The original proposal to add a visual marker to the components in the workspace is unlikely to provide a quick and complete overview for complex models.

I recently found that the initialization diagnostics app basically provides such an overview. Unfortunately, it doesn't always work, and sometimes it lists components that are set to ignore (see Q1 and Q2 in https://www.mapleprimes.com/questions/234537-Initialization-Diagnostics-Questions). Also, it is not possible to quickly check and change ICs in the model workspace (complex models can have many components with similar names, which makes finding components even more difficult).

For these reasons, I think a new item in the Model Tree for filtering components with ICs set would be the best place for a quick and complete overview.  A click on a list element would provide direct access to the ICs for checking and/or changing.

I have already submitted a software change request, but cannot provide more background to it. So I do it here.

@dharr 

I was not aware of this type of routing in the schematics. MapleSim uses the same type of routing for several physical domains, including electrical. Connections to a connection line are modeled with a dot. Such a connection is not mandatory. I (and probably other users) prefer to connect component to component. In such situations, ambigeous layouts are possible because MapleSim adds gaps to the routing where the lines are actually connected. Gaps are also added when connection lines cross.
It seems that this new way of layouting does not require gaps. How it works in multidomain layouts is hard to say without trying it.

Thanks for pointing out the new way of layouting.

@one man 

Perhaps the difference can be explained by the type of joints? Does your model correspond to the use of universal joints?

I used exclusively revolute joints.

First 57 58 59 60 61 62 63 Last Page 59 of 67