Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@Kitonum Be careful with has.  It works fine here, but could be problematic for a more general problem where L1's sets contained other than integers. Suppose

L1 := [{2,3},{2,f(3)}, ... ]:

@Mac Dude A user should be able to globally configure a package, say by making a suitable addition to the Maple initialization file, without loading the package, otherwise the package would always be loaded whenever Maple was used, regardless whether the package was being used. This precludes making the configuration mechanism local to the package, because accessing it would load the package.  Thus the use of globals.  The issues you dealt with are precisely the ones I'm dealing with. 

The Configure object I proposed does solve the problem, but it seems overkill and I don't like the access mechanism; using a member operator (foo:-default) is nicer than an index (foo['default']). A record that strictly enforced its types would be close to ideal.  Some packages might have options that cannot be completely validated via a type, so a more general mechanism could be occasionally useful.

One way to implement that in a Maple worksheet is to add a few embedded components, say a text area to accept the user input, a button to process it, and a math container to display the output.  Is that what you have in mind?  Or something different?

@vanzzy Please don't post an image of the equations; nobody want's to retype them.  

For the quickest and must useful response, it is generally best to upload the worksheet to this site.  Use the green up-arrow on the toolbar (here).

What equations do you want for HW5DC, the motor/pendulum?  The closed loop equations for the entire system, including the step source?

@Carl Love Really clever technique (though the Matrix operations are considerably slower).  The use of the assignment operator as a first order expresssion, for example, y := (x :=1), is new for Maple 2018 (I believe) and the documentation for it a bit sparse, see the penultimate bullet in the Description of the help page for assignment.

Further How long did it take for the loop that assigns T to complete? That needs to be rethought.

Later Am thinking much of the time is wasted allocated memory for the internal array used to compute the product.  The row vector can be eliminated by using add:

   in P do
           T[(v := add(pm.t))] := T[v] + 1;
        od:

That helps, but there is still the memory allocation for pm.t. Ideally one could avoid that by doing something like

   V := Vector(3):
   in P do
           T[(v := add((V := pm.t)))] := T[v] + 1;
        od:  

Not too surprisingly, there is no change because the Matrix-Vector product always allocates memory for the result. That could be avoided with a suitable call to a routine, but that is less nice.  For example,

VMT := proc(V,M,T)
local i,j;
    for i to 3 do
        V[i] := add(M[i,j]*T[j], j=1..3);
    end do:
    V;
end proc;
V := Vector(3):
in P do
         T[(v := add(VMT(V,pm,t)))] := T[v] + 1;
     od:

Despite handling the matrix-vector product manually, that is considerably faster because no additional memory is allocated.  There should be a nicer (prebuilt) way to do this, but I'm not aware of it.

@brian bovril I don't understand that part; it seems to contradict the whole point of the exercise.

Show an example of what you have done.

Could you upload the msim here?  Use the green arrow.

I cannot tell what you really want, but suspect that assign(Equate(C,A)); would achieve it. The effect of the assign is to create a procedure named c with a remember table.

@aaeerr First, I copied that code from the displayed code shown in the code region in the Equation Extraction app, then added the statement at the end.  The code goes into a worksheet that is linked to the MapleSim model. You could also run it standalone, in a separate Maple worksheet, by changing the first statement to something like

A := MapleSim:-LinkModel('filename' = "HW4.msim"):

then continuing with the other commands. Here's a brief explanation of what each line does

Connect to the the MapleSim model. A is assigned a Maple module with exports that allow interacting with the linked model.

A := MapleSim:-LinkModel('filename' = "MW4.msim"):

Select the subsystem of interest. This isn't necessary because you are interested in the entire model.

A:-SetSubsystemName(""):

Define shorter names for the parameters and variables of interest. You can use A:-GetParameters('allparams') to list all the parameters, and A:-GetVariables() for the variables.

A:-SetSubstitutions([`Main.SpringDamper.c` = c__SpriD, `Main.SpringDamper.d` = d__SpriD, `Main.SpringDamper.phi_rel0` = PhiR0__SpriD, `Main.Revolute.M`(t) = M__Revolute(t), `Main.Revolute.theta`(t) = theta__Revolute(t)], 'nocheck'):

Get the equations. See the help page for LinkModel,GetEquations for the options.

eqs := A:-GetEquations('output' = 'all', 'inputs' = {}, 'filter' = [], 'simplify' = true, 'params' = {`Main.SpringDamper.c`, `Main.SpringDamper.d`}):

Get the differential-algebraic equations. Note that the lhs should really be named daes; the displayed code has a typo which prevents the next line (in the app, not here) from working.

dae := eqs[1];

Call isolate to isolate the variable M__Revolute(t) in the second equation in daes (this assumes the ordering is consistent, which may not be case) to the lhs, then call subs to eliminate it from the first equation.

subs(isolate(dae[2],M__Revolute(t)), dae[1]);

@Basak My mistake.  I had put your code in a procedure to permit easier debugging but didn't declare all variables as globals.  Doing so masks your problem. What is actually happening is that tj is assigned NULL. Put a print statement after the call to tj := solve(eqtj,tj) and you'll see the problem.  Maybe that should be solve(eqtj, p)?

@acer A chance for the rarely used mul:

mul(GE[i,i],i=1..2)

@acer Nice extension.

First 21 22 23 24 25 26 27 Last Page 23 of 195