How do I use fmi2SetReal in C++ to set the value of an input parameter to simulate from an FMU model? - c++17

I am trying to use the fmi4cpp API in C++ to run a simulation from a FMU and I would like to set some input parameters. What's the best way to do that for (1) fixed parameters and (2) continuous inputs? I bumped into the fmi2SetReal function but I struggle finding practical examples.
Thank you very much.

Using fmi4cpp, the call to fmi2SetReal is handled through the write_real functions in your slave instance. Location in source

Related

Can I add more functions to System.Linq.Dynamic.Core?

I am using System.Linq.Dynamic.Core to parse custom statistical templates, and was wondering if it is possible to somehow extend the library's functionality to parse more mathematical functions. Specifically, I needed in this instance to calculate the absolute value of a variable. I have managed to do this with the already supported "iif" function (i.e. "iif(a>-a, a, -a)"), but I was wondering if there is a way to extend the library to add an "abs()" function, and similarly other functions I may need in the future (such as square root etc).
Any pointers to the right direction?
The System.Linq.Dynamic.Core library is not really designed for this extensibility.
However, you can take a look at the System.Linq.Dynamic.Core.Parser.ExpressionParser.cs for examples, like the IIF you already mention.

Passing output of a TestStep to another TestStep

In the Keysight OpenTap
There is Test- Step 1. I would like the pass the result obtained by Test-Step 1 to any of the Test-Step-n
Example : Test-Step1 executes SCPI Query and then the result obtained from this, has to be passed to Test-Step-N.
For this approach, we have extended a Test-Step and created our own Test Step.
Is there any in-built feature In TAP we could make use of it?
Are you asking for this feature to be provided by the built-in 'Basic/Flow Steps'?
Input/Output parameters are fully supported by the OpenTAP engine and as you point out, you have created your own TestStep which I assume has utilised this approach.
Any generic Teststep that would consume the output of another TestStep would need to understand the data to make any use of it other than in the simplest of cases.
Do you have a specific example?

Use of extension functions in streaming mode in Saxon/Net

I would like to know whether it is possible to call user extension functions in streaming mode using XSLT 3.0 on Saxon EE for .Net.
And if it is, under what constraints (e.g. "never pass nodes as parameters but atomic values are OK", etc.)
I have looked at the main documentation but could not find anything.
I don't think it's been tested, so I suggest you try it and see. The streamability analysis uses the general streamability rules, so if you pass atomic values (or unstreamed nodes) then it should be OK. You might be able to get away with passing nodes as well, provided you don't try doing any downwards navigation from them. If you pass a sequence of nodes rather than a single node then they may get buffered.

Maxima: How to add superscript to a symbolic variable?

How can I add a superscript to a variable, when I try to type it in to the Maxima Computer Algebra System?
So for example, I would like to have variables named U^(AC), U^(DC) where my intention is not to raise the variable to the power of something, but to have it as part of its name.
UPDATE, NEW ANSWER: Code to implement presuperscripts, presubscripts, postsuperscripts, and postsubscripts has been merged into Maxima. It is available now in the current version from Git, and it will be included in the next release of Maxima, which will be Maxima 5.44. See declare_index_properties in the online documentation (via ?).
OLD ANSWER: There isn't a built-in way to achieve that. That said, to some extent you can use A^B as a symbolic variable in some ways, depending on what you are trying to do. For example, given e:X*A^B + Y you can say solve(e, A^B) and it will return [A^B = -Y/X]. If you say more about exactly what you are trying to achieve, I might be able to give more specific advice.
A while ago I wrote some code to enable Maxima to treat indices of variables as subscripts as well as subscripts (as put the indices before as well as after the variable). I will dust off that code and write more about it here.
You can name it like that :
U^"AC"
U^"AC"*2=456; solve(%, U^"AC");
But it is a good idea to 'define' it before with something like :
UAC : U^"AC"; UAC *2=456; solve(%, UAC );

Erlang: Compute data structure literal (constant) at compile time?

This may be a naive question, and I suspect the answer is "yes," but I had no luck searching here and elsewhere on terms like "erlang compiler optimization constants" etc.
At any rate, can (will) the erlang compiler create a data structure that is constant or literal at compile time, and use that instead of creating code that creates the data structure over and over again? I will provide a simple toy example.
test() -> sets:from_list([usd, eur, yen, nzd, peso]).
Can (will) the compiler simply stick the set there at the output of the function instead of computing it every time?
The reason I ask is, I want to have a lookup table in a program I'm developing. The table is just constants that can be calculated (at least theoretically) at compile time. I'd like to just compute the table once, and not have to compute it every time. I know I could do this in other ways, such as compute the thing and store it in the process dictionary for instance (or perhaps an ets or mnesia table). But I always start simple, and to me the simplest solution is to do it like the toy example above, if the compiler optimizes it.
If that doesn't work, is there some other way to achieve what I want? (I guess I could look into parse transforms if they would work for this, but that's getting more complicated than I would like?)
THIS JUST IN. I used compile:file/2 with an 'S' option to produce the following. I'm no erlang assembly expert, but it looks like the optimization isn't performed:
{function, test, 0, 5}.
{label,4}.
{func_info,{atom,exchange},{atom,test},0}.
{label,5}.
{move,{literal,[usd,eur,yen,nzd,peso]},{x,0}}.
{call_ext_only,1,{extfunc,sets,from_list,1}}.
No, erlang compiler doesn't perform partial evaluation of calls to external modules which set is. You can use ct_expand module of famous parse_trans to achieve this effect.
providing that set is not native datatype for erlang, and (as matter of fact) it's just a library, written in erlang, I don't think it's feasibly for compiler to create sets at compile time.
As you could see, sets are not optimized in erlang (as any other library written in erlang).
The way of solving your problem is to compute the set once and pass it as a parameter to the functions or to use ETS/Mnesia.

Resources