Joe Riel

9520 Reputation

23 Badges

18 years, 224 days

MaplePrimes Activity

These are answers submitted by Joe Riel

By Geometric Algebra I assume (didn't open the link) you mean David Hestenes' take on Clifford Algebra.  There is a Maple package for Clifford Algebra, named Clifford I believe, by Rafal Ablamowicz.  I haven't looked at it in a long while.  At that time I wrote a package, named Glyph, for doing Clifford Algebra in Maple, but it is much out of date.  Ian McCreath revised it a few years ago, for his own purposes, mainly for study, I think.  I could ask him to contact you.  Writing a Maple package for this is a a great way to learn.

As tomleslie suggested, posting an example would be helpful.  Piecewise expressions that don't depend on solving variables (currents and voltages) should already be doable; if not, I'll extend Syrup. Piecewise expressions that depend on solving variables would be really useful, but its unlikely I'll implement them.

White-space is not needed after the closing parenthesis in the formal parameter sequence of a procedure statement.  For example


There are places where white-space is required, say after a for.

Later Actually, you technically don't need white-space even after a for, and possibly not anywhere, though the alternative is rather ugly.  I'll leave that as a puzzle for now.

For strings you can also use seq, at least with newer versions of Maple.  Maybe not Maple 18.

                  "a", "b", "c"


There are a few problems with the circuit.

A full bridge rectifier should not be grounded on both sides.  Float the source (the sinewave current source).  Connect the return path of the bridge to the current source (in the model it is unconnected).

The impedance of the load (C1 and R2) is too low.  The peak source current is 45uA, you cannot drive a 1ohm resistor and see more than 45uV.  Increase it to something much higher, say 1Mohm.  C1 should be much smaller, maybe 1nF.

At 40Hz (the frequency of the sine wave), the impedance of the 171nF cap is 23e3, which limits the peak voltage to about 1V.  I'm not familar with piezoelectric devices, so have no idea whether the model is reasonable, but to get a significant voltage out of it in that configuration the capacitance has to be much smaller.

Make all the diodes the same; you can do this by selecting all of them and using the common parameter tool.  Currently they have a mix of values.  Set Vknee to 0.7 and Goff to 0.

A useful way to debug this, and other circuits, is to test in pieces. With MapleSim this is fairly easy. For example, you can disable everything to the right of the piezoelectric model (select the parts and click the enable/disable icon on the toolbar), add a temporary ground, then check whether the voltage across the piezoelectric device produced is reasonable.

Just a heads up; I'll be uploading an extension to Syrup sometime soon---probably within a week or two.  Nothing big, but it will allow diodes, subcircuits, and probably op-amps in ladder notation.  Will post to MaplePrimes when its ready.

It's not clear to me what you are attempting to do, but the implementation isn't going to work.  Here's why.

The voltage at the non-inverting input of the lower op-amp (probe1) is 0.3V.  For the op-amp to be in the linear region, the inverting input (probe 2) should be at that same voltage (0.3V).

The voltage at the non-inverting input of the upper op-amp is 0.5V. So the voltage at the inverting input should be 0.5V. So the highest voltage attainable at probe 2 (assuming mosfet had zero resistance) is  0.5V*R4/(R4+R5) = 0.5V/11 < 0.05V < 0.3V.  There is no chance that the lower op-amp is in the linear region. 

Thomas Richard's answer is the right one.  Another point; that design isn't going to work (I haven't actually tried to simulate it); there is a problem when switch1 is open as the constant current source has nowhere to go.  A crude solution would be to add a diode clamp to a voltage source greater than the fully charged battery.  Better would be to use a signal current source, turning it on to charge and off when the battery is sufficiently charged. 

The error message is giving you a useful hint.  Change to a stiff solver:  click the "wrench" on the right vertical toolbar and select "Rosenbrock" from the Solver menu.

There are two other relevant issues.  First, the output resistor (R3) has its default value, 1ohm, which is rather low for a typical op-amp. Pick a more reasonable value, say at least 1K.  Second, the op-amp needs a negative rail; in the given model the negative rail input (m) is grounded.  Connect it to, say, -10V.  That will allow the circuit to work properly during the blocking phase.

As C_R suggests, you can use the ideal opamp here.  If you don't care about the op-amp characteristics (say effects of limited bandwidth, output impedance, etc) that is frequently the way to go if it works, however, it won't work in all circuits.  The ideal op-amp merely enforces a virtual ground between its two inputs; it won't work in a switching circuit (say as a comparator).

The circuit is missing a positive bias for the drain of MNMOS2 so that circuit would never perform properly. Also, the two NMOS devices are missing model card parameters.  Alas, fixing those issues won't help here; the mos devices from the SPICE3 library don't work particularly well in MapleSim.  You can model this using the standard mos devices, see current_mirror2.msim, in which I added slightly mismatched resistors and a supply with a ripple voltage so that you can see some mismatch in the currents.

Use unapply.

b := unapply(a(x)+x^2, x);

An alternative approach is just use expressions:

a := x + 1:
b := a + x^2:
a := x + 5:

To evaluate, say, b at x = 3 you could do

eval(b, x=3);


There is more here than meets the eye.  Here's a modification that suggests what is happening:

(**) f := proc(n)
(**) option remember;
(**)     if n < 2 then 1;
(**)     else
(**)         f(n - 1) + f(n - 2);
(**)     end if;
(**) end proc:
(**) F := Compiler:-Compile(f):
Warning, the function names {f} are not recognized in the target language
(**) unassign('f');
(**) F(10);
Error, (in F) number expected for float[8] parameter, got f(9)

Note my use of unassign.  The compiler warning is a hint.  If the unassign is removed, then F(10) returns the correct answer, but only because it is evaluating f in Maple.  To allow recursion to work you can replace the calls to f with thisproc:

(**) f := proc(n)
(**)     if n < 2 then 1;
(**)     else
(**)         thisproc(n - 1) + thisproc(n - 2);
(**)     end if;
(**) end proc:
(**) F := Compiler:-Compile(f):
(**) F(10);


I'm not sure what you are actually looking to achieve.  I believe the custom component shown in the video was created using Modelica Code Editor, which allows more functionality then the Custom Component app, however, you can use a boolean parameter (which is what the solution parameter appears to be) in the Custom Component app to select a branch of a piecewise.  For example

eq := [ diff(x(t),t) = %piecewise(b, sin(t), cost(t)) ]; 

In the app, set the b parameter to type Boolean. It will then appear as a checkbox in the parameter panel of the generated component.

You defined the force on the mass as -9.81*m, where m is a parameter.  However, you didn't assign the mass (SM1) the parameter m, so the force doesn't correspond to gravitional acceleration.  Also, the the mass-with-stop-and-friction component has additional mass not accounted for in the force model.  

If you use the multibody mass component, it will, by default, have the downward acceleration of Earth's gravitional force applied to it.  Then you won't need the external force component. I've uploaded a modified version.  It doesn't include stops.


If you first execute stoperror(traperror), the debugger will open at the occurrence of the assertion that causes the issue.  The library code contains

                  dz1 := numer(normal(diff(z1,x)));
                  ASSERT( degree(dz1,sol) = 1 );
                  dz1 := normal( -coeff(dz1,sol,0) / coeff(dz1,sol) );

but at that point z1 is _X000001+exp(x^2)*exp(-x^2), so dz1 is 0 and the assertion fails.  With assertlevel=2, the ASSERT command raises the error, otherwise the subsequent statement raises a division by zero error.

3 4 5 6 7 8 9 Last Page 5 of 114