Joe Riel

9615 Reputation

23 Badges

19 years, 200 days

MaplePrimes Activity


These are answers submitted by Joe Riel

They can be connected, however, the input is vectorized, which requires an additional step to select which slot of the vector to connect to.  I generally start from the output gate and draw the connection to the input gate, hovering over its input section (left side) until I see the green highlight, then click. That should make a connection, typically (maybe always) to the first slot. Then select the signal (click on the line) and you should see, in the upper right pane a display like A2.y <--> N1.x[1].  That means the output (A2.y) is connected to the first slot of the N1.x.  Use the drop-down menu that appears in that pane to change this to, say N1.x[2]. 

Here is the updated model.

logical_circuit2.msim

DEtools is rather old and is not a Maple module, but rather a table-based package.  As such, I'm surprised DEtools:-kovavicsols even works, though maybe there is now a mechanism to handle that (use of the member operator, :-, with a table-based package). Try

eval(DEtools[kovacicsols]);
    proc() `DEtools/kovacicsols`(_passed) end proc

Based on that, I'd modify your code to use either DEtools['kovacicsols'] or `DEtools/kovacicsols`, which is the procedure that is eventually called.

As the help page for edge with init part states, the output will only ever be true for an instant, so on a plot will appear to be always false (0). The output should drive a block that that responds to an edge.  In the attached model it is driving a triggered sampler; you can see the output of the sampler change.

test2.msim

The immediate issue is the assignment L*i(0) := 2000.  The lhs of an assignment should typically be a name, hence the error message.  Admittedly, error message is a bit obtuse; that appears to be a consequence of using 2D math for the input.  Using 1D math gives the more useful message

L*i(0) := 2000;
Error, invalid left hand side of assignment

 

By way of example

LibraryTools:-FindLibrary(Syrup);
                        "/home/joe/maple/toolbox/Syrup/lib/Syrup.mla"

 

A necessary condition for the two lists of vectors to be equal under a permutation of the vectors is for the two lists to be equal as sets with each vector converted to a set.  This should be cheaper to test and allow the expensive test to be run less often.  Whether it is useful depends how frequently the mismatch occurs. So

Cheap := proc(L1, L2)
local S1, S2;
   S1 := convert(map(convert, L1, 'set'), 'set');
   S2 := convert(map(convert, L2, 'set'), 'set');
   evalb(S1 = S2);
end proc:

 

I've seen that more than a few times. Am not sure the origin (it's a kernel thing).

The emacs maple debugger (mdcs) doesn't resolve that issue.  Am working on updating the github site for mdcs, will post a message to MaplePrimes when it is ready.

Followup Got a response from the kernel group. Some Maple procedure do, in fact, change in place, which causes issues with the debugger.  I had submitted SCRs for this years ago and was kindly pointed to them. One case where a procedure can change in place is if it modifies itself to add a remember table. I think that now can be done in an alternative way that avoid the change in place, but the example was in some rather old library code.

To use the debugger to step through code, the code has to be in a procedure.  However, you did say that the code was crashing. Am not sure what that means, but if it is raising an error, than you can use that to launch the debugger. For example,

(**) stoperror('all'):
(**) for i to 10 do 1/(i-3); end do:

Executing that will launch the debugger when the error is raised and display the expression raising the error.  Inside the debugger you can inspect the variable i. Maybe this will suffice for your problem.

Is this what you have in mind

(**) with(DynamicSystems):
(**) tf1 := TransferFunction(z/(z^2+z+1),'discrete'):
(**) de1 := DiffEquation(tf1):
(**) de1:-de;
           [x1(q + 1) = -x2(q), x2(q + 1) = x1(q) - x2(q) - u1(q), y1(q) = -x2(q)]

This is consistent with your other issue.  Apparently the Maple version launched by emacs is not reading the .mapleinit file.  Am investigating [it works for me].  Will contact you separately but report any results here. 

Note that it is generally best if the initialization file produces no printable output.  So it is better to terminate the assignment with a colon (vs a semicolon).  That won't matter here.

Rather than use the maplev-mode on git (which I haven't updated in a while, if memory serves), use the one available on the Maple Cloud.  That is, in Maple Standard, click the icon in the upper left that opens the cloud interface.  Search for maplev, then follow the instructions. 

An alternative is to use

s := "   string with   various    spaces    ":
StringTools:-RegSplit(" +", StringTools:-TrimLeft(s));
                        "string", "with", "various", "spaces"

TrimLeft is used to remove a prefix of white space, which would otherwise be returned as an empty string in the sequence.

I assume you are running this in Standard.  In tty Maple (cmaple) it behaves better (no lockup) but still somewhat strangely as it doesn't debug the second call.  This is on linux.  I assume the lockup occurs in Standard because the debugger window was killed.  If I use my Emacs-based Maple debugger, it works fine in both tty Maple and Standard: no lockup and one can debug either call. 

You may be able to use the liesymm package to handle this.  The difforms package can also be used, but I believe the lieysmm package is easier to use.

(**) with(liesymm):
(**) setup(x,y):
(**) eq := 2*x*y^3 + 3*x^2*y = 1;
(**) isolate(d(eq),d(x));
                       d(x) = (-6*x*y^2*d(y)-3*x^2*d(y))/(2*y^3+6*x*y)
(**) factor(%);
                       d(x) = -3/2*d(y)*x*(2*y^2+x)/y/(y^2+3*x)

 

There are a couple issues, at least if you are doing this in 1D input.  The following works.  Note that I replaced Zeta with zeta, the former is assigned a procedure and won't work.
 

with(LinearAlgebra);
with(plots);

Nx := 200;
Nt := 200;
dx := 0.5e-2;
dt := 0.2e-1;
A := Matrix(Nx, Nx);

for k to Nx do A[k, k] := -2.0 end do:
for j to Nx-1 do A[j+1, j] := 1.0 end do:
for j to Nx-1 do A[j, j+1] := 1.0 end do:
A;

zeta := (.1*dt/dx)^2;
phi || 0 := Matrix(Nx, Nx);

fin := proc (t) options operator, arrow; cos(4*Pi*t) end proc;
phi || 0[(1/2)*Nx, (1/2)*Nx] := fin(0);
phi || 1 := (1/2)*zeta^2 . A . phi || 0;
phi || 1[(1/2)*Nx, (1/2)*Nx] := fin(dt);

phinow := Matrix(Nx, Nx);
phinext := Matrix(Nx, Nx);
phibefore := Matrix(Nx, Nx);

phinow := phi || 1;
phibefore := phi || 0;

for j from 2 to Nt do
    phinext := zeta^2 * (A . phinow + phinow . A) + 2.*phinow - phibefore;
    phi || j := Matrix(Nx, Nx);
    phinext[(1/2)*Nx, (1/2)*Nx] := fin(j*dt);
    phi || j := phinext;
    phibefore := phi || (j-1);
    phinow := phi || j
end do;

 

5 6 7 8 9 10 11 Last Page 7 of 114