Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » Enderdead14
  • » Profile

Posts

Posts

Nov-02-21 09:38:27
Some questions about how to manage jacobian computation

Hello there,

I'm trying to implement a communication block on OMC in order to communicate through grpc with other remote process in differents language (e.g python). 
This block has to be discrete and take all observations variables and produce new state for the output variable.

In my first attend to do this using external C++ source code, I had some issues with NLP solver. Indeed, the OMC solver tried to estimate the Jacobian of my brand new block which is of course  meanless. At that time, I didn't found any method/annotation to declare this block as non differentiable. If you have an idea to solve this problem, I'm a taker.

In order to solve this issue, I decided to implement one block for data sending and one block for data receiving. Doing this avoid to compute the jacobian of the grpc communication.  I have figured out last week that my discret block which send data isn't called at every sampling period !!!!
I'm guessing that is due to solver optimization trick. But this is very harmfull for my communication block (since some data are missing....).
So my second question is : Can we force the solver to compute the discret block at each sampling rate, even if it's do not interact with the system dynamic (cause I had to cut the link for avoiding jacobian calculation).

In order to be more explicite, this is my sender discret block :

Code:

block Receiver

  parameter Integer index=1 "Number of outputs";
    extends DiscreteBlock;
  Modelica.Blocks.Interfaces.RealOutput y "Connector of Real output signals"
    annotation (Placement(transformation(extent={{100,-10},{120,10}})));
   
  function grpcGetter
    input  Real t;
    input  Integer index;   
    output Real y;
   
  external "C" annotation(Library={"-lprotobuf", "-lgrpc", "-lgpr", "-lgrpc++", "grpc_interface"},
  LibraryDirectory={"openmodelica-python-gym/motor_model/"},
  IncludeDirectory={"openmodelica_python_gym/external_lib/grpc_interface"});
  end grpcGetter;

  Real t(start=0);
   
    equation
    when { sampleTrigger } then
        y = grpcGetter(t, index);
    end when;
    der(t) = 1;

end Receiver;

Many thanks in advance to the people who will try to help me.

  • Index
  • » Users
  • » Enderdead14
  • » Profile
You are here: