Hi,

As far as I know dasrt is using variable time step during integration.
Of course, people which know more about this, please invalidate me :)

You can tell dasrt to output results at certain steps and
you do that via the parameters you give for the simulation:
timeStep = (stopTime-startTime)/numberOfIntervals, but that
doesn't mean that when it call an external function it will
do it at a specific time. It may call it 20000 times in a
time step.

If you want to feed values synchronously I guess (I'm not not
100% sure until I test it) you can do it in a when clause.

when sample(time, 0.5) then
 newVar = call_to_your_function();
 // you might even need to use reinit(var, newVar)
 // here but again I'm not sure
end when;

When the condition in the when clause is reached the solver returns
(due to a zero crossing event, here generated by sample) and then
the simulation runtime runs the discrete part of the system and if
there are no more events it enters again the simulation loop.

Well, please take what I said with an open mind as I'm not the best
guy to comment on this. Any other input from other more qualified
people is welcome (to me too as I may learn more)!

Cheers,
Adrian Pop/

[EMAIL PROTECTED] wrote:
Hi

the new OpenModelica "morning-build" that fixes the error: http://www.ida.liu.se/~pelab/modelica/OpenModelica/OMC/nightly-builds/


Great, thanks again!

I don't quite get why would you want to use an external function that returns the same value

I wanted to test the external function mechanism. Since it didn't
worked the first time I tried a minimal configuration - an
argument-free function.

Maybe the function even stays that way - without arguments. All I
want to do is feed the model input data externally. The question is
when to provide a new value. I'm going to synchronise that from the
runtime library code. Though I have a small issue with that. I
figured solver_dasrt.cpp line 239 would start the main simulation
loop. Yet simulation time only counts up every 5th loop run with the
model used (time step of 0.005). Is there some way of tackling the
definite start of a new time step from the code?

Regards, Alexander


but is not my place to complain and I'm glad you did as it exposed
a bug in the compiler :) Thanks for reporting it!

Cheers, Adrian Pop/

[EMAIL PROTECTED] wrote:
That was fast. Thank you Adrian!



-----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Adrian Pop Gesendet: Montag, 20. Oktober 2008 13:25 An: [email protected] Betreff: Re: External functions without arguments are not found


Hi,

I found and corrected the bug. I'll test it a bit more before I commit the fix. I'll then generate a new nightly-build later today
 and get back to you when is available.

Cheers, Adrian Pop/

Adrian Pop wrote:
Hi,

This is clearly a funny bug. It should work. I'll have a look at
it and let you know when is fixed.

Cheers, Adrian Pop/

[EMAIL PROTECTED] wrote:
Hi,

I tried the ExternalLibraries example from the User Guide in
the testmodels directory of the 1.4.4 release. It worked fine.

Then I wanted to change one function to take no arguments. That
didn't work. Did I do something wrong or is this a bug? Description follows.

Regards, Alexander


I changed ExternalFunc1_ext() to take no arguments. Changed all
 the signatures and implementations. Like in the C file:

double ExternalFunc1_ext() { return 2; }

And in the model:

function ExternalFunc1 output Real y; external y=ExternalFunc1_ext() annotation(Library="libExternalFunc1_ext.o", Include="#include\"ExternalFunc1_ext.h\""); end ExternalFunc1;

With a later call to:

der(x)=-ExternalFunc1();

Running the script gives off:

runScript("ExternalLibraries.mos") "true 0 0 record resultFile =
"Simulation failed. No matching function found for ExternalFunc1() of type function() => Real, candidates are function() => Real Error occured while flattening model ExternalLibraries " end record

true"



Reply via email to