Joe Riel

9575 Reputation

23 Badges

19 years, 52 days

MaplePrimes Activity


These are replies submitted by Joe Riel

@nm Did you try

stoperror(traperror["module does not export"]);

which can typically be reduced to, say,

stoperror(traperror["module"]);

A minor correction.  % is assigned the last computed expression, not the last entry. You want to reinsert the last input, as a new input. Command line maple has access to the history, but not Standard.  A slightly more general operation would a short-cut that selected the input in an execution group.  You can select the execution group using Ctrl-Alt-Shift-E, but that also includes the output.

@yalda_amd It runs fine here.  Am thinking the issue is with your installation.  Maybe something is corrupted.  Contact Maplesoft support.

Could you upload the msim file.  Just reply and use the big green arrow (at this site).

It's probably not a bad idea to write-protect the DirectSearch.mla (after installing a new one) to prevent that from recurring. Of course, I've never bothered.  Have occasionally written to the wrong mla and wondered why subsequent restarts aren't doing what I expect.

How did you create the custom library?  From modelica source?  If you'd like you can upload here or email me the modelica and I can take a look.  What version of MapleSim do you have?

@Carl Love Oops.  Thanks.  Fixed it and added a condition to return true if both lists are empty.

@Felipe_123 My suggestion assumed that. As mentioned, it (Cheap returning true) is necessary but not sufficient.

Here's a brute-force method.
 

Full := proc(L1 :: list, L2 :: list)
local P, S, S1, k, p, v;
    if L1 = [] then return evalb(L2 = []); end if;
    S1 := convert(map(convert, L1, 'list'), 'set');
    P := Iterator:-Permute(numelems(L1[1]));
    for p in P do
        S := {seq([seq(v[k], k=p)], v=L2)};
        if S = S1 then
            return true;
        end if;
    end do;
    return false;
end proc:

L1 := [<0|0|0>,<2|1|2>,<1|2|1>]:
L2 := [<1|1|2>,<2|2|1>,<0|0|0>]:

Cheap(L1, L2);
Full(L1, L2);

L1 := [<0|0|0>,<0|0|0>,<1|2|1>]:
L2 := [<1|1|2>,<2|2|1>,<0|0|0>]:

Cheap(L1, L2);
Full(L1, L2);

With Maple 2021 you could use orseq to make the code a bit smaller

Full := proc(L1 :: list, L2 :: list)
local P, S1, k, p, v;
    if L1 = [] then return evalb(L2=[]); end if;
    S1 := convert(map(convert, L1, 'list'), 'set');
    P := Iterator:-Permute(numelems(L1[1]));
    orseq(S1 = {seq([seq(v[k], k=p)], v=L2)}, p=P);
end proc:

 

@nm A version of the debugger is on my GitHub site, https://github.com/JoeRiel/mdcs, however, I haven't updated that lately so please don't install it. There are a few screenshots there and a description of its capabilities.  While I don't use Windows much, it does work there, at least the last time I tried it. If you (or anyone) are interested, please contact me directly and I'll get you set up with the latest version.  If you are familar with Emacs, life will be easier.  Regardless, expect to invest some time getting it operational.  While I'm clearly biased, I will say that it makes debugging Maple code much nicer.

@wswain Why not try enclosing the code in a procedure, instrumenting that, then debugging it?  I write all my maple code in procedures precisely for that reason.  Doing so will cause some of the variables to be declared as locals.  If that isn't suitable, you can manually add a global statement to declare them as globals.

@wswain You can step through the Property procedure, just instrument it and execute code that calls it.  For example

with(ThermophysicalData[CoolProp]):
stopat(Property):  # launch debugger when the Property export is called.
Property(density, temperature=300, pressure=1*Unit(atm), Water);

The call to Property will launch the debugger.  You can then step through the procedure and into the subprocedures that it calls.  An alternative approach is just trace the procedure.  For example
 

(**) restart;
(**) with(ThermophysicalData[CoolProp]):
(**) trace(Property):
(**) Property(density, temperature=300, pressure=1*Unit(atm), Water);
{--> enter "Property |lib/ThermophysicalData/CoolProp/src/interface.mm:498|", args = density, temperature = 300, 
pressure = Units:-Unit(atm), Water
                                                    has_units := FAIL

                                                    fluid := "Water"

                                                   output := "density"

                                     inputs := [temperature = 300, pressure = [atm]]

                                           result := ["T", 300., "P", 101325.]

<-- exit "Property |lib/ThermophysicalData/CoolProp/src/interface.mm:556|" (now at top level) = 996.5569353*Units:-Unit(
kg/m^3)}
                                                               [ kg ]
                                                   996.5569353 [----]
                                                               [  3 ]
                                                               [ m  ]

I rarely use trace, preferring the interactivity of debugging. Full disclosure, I also rarely use the builtin debugger, instead relying on an Emacs-based version with a better interface. 

@filiporlo There is a straightforward transformation from a transfer function to that form.  Given a transfer function in the form N(z)/D(z), with N and D polynomials in z, you can do it manually by cross-multiplying that with Y(z)/U(z) to get D(z)*Y(z) = N(z)*U(z), then factoring out the leading term, rearranging and converting z^(-k)*Y(z) to y(q-k), similarly for the terms with U(z), that is, computing the symbolic inverse z-transform, term by term.  This can be easily coded into Maple.  Here's a quick and dirty attempt.
 

TFtoDE := proc(tf :: algebraic)
global q, z, u, y;
local a, den, k, nd, nn, num;

    num := numer(tf);
    den := denom(tf);

    if not num :: polynom(anything, z)
    or not den :: polynom(anything, z) then
        error "transfer function can not be handled";
    end if;

    a := lcoeff(den);

    num := num/a;
    den := den/a;

    num := PolynomialTools:-CoefficientList(num, z);
    den := PolynomialTools:-CoefficientList(den, z);

    nn := numelems(num);
    nd := numelems(den);

    if nd < nn then
        WARNING("improper transfer function");
    end if;

    y(q) = ( add(num[k]*u(q+k-nd), k = 1..nn)
             - add(den[k]*y(q+k-nd), k = 1..nd-1) );
end proc:

Now applying it to a typical example
 

TFtoDE(3*z/(z^2+z+1));
                 y(q) = 3 u(q - 1) - y(q - 2) - y(q - 1)

 

@Carl Love Hmm.  I suppose it's a personal preference.  I generally interact with maple via tty maple and don't want to see any superfluous output when launching it, which would be the case if the initialization file produced output.

@Thomas Dean The problem there was that I had used the MELPA identifier for the button-lock package, which is based on the date, rather than a version.  Not sure the best way to fix that.  Do you know where you got button-lock from?

@nm Yes, I can reproduce the lockup issue in Standard.  I'll submit as a bug.

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