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
  • » ehourston
  • » Profile

Posts

Posts

Hi,

I am encountering this same error. I am trying to simulate a fluid (valve) system and am getting the following error:

Code:


[3] 12:04:41 Symbolic Error
[Modelica.Fluid.Interfaces: 13:5-14:68]: Found equation without time-dependent variables: port_a.m_flow = 0.0

What does this error mean and how, generally speaking, do you resolve the issue? Thanks.

Apr-13-21 21:44:00
Function has more than one algorithm section or external declaration
Category: Programming

Great, thank you for the clarification.

Apr-13-21 21:02:57
Function has more than one algorithm section or external declaration
Category: Programming

Thank you for your quick reply. Yes, there is an algorithm section in the partial function but it is empty (default). Removing the keyword solves that error. To better my understanding, would you mind explaining why that was an issue? Many thanks.

Apr-13-21 20:52:50
Function has more than one algorithm section or external declaration
Category: Programming

Hi,

I am trying to call a function using some input values (see equation section). When I check the Intake model below, I get Translation Error: Function solveSCFM has more than one algorithm section or external declaration. Any ideas what is causing this error? Thanks.

Code:


model Intake
  extends Modelica.Fluid.Interfaces.PartialTwoPortTransport;
 
  input Real RPM;
  output Real SCFM;
  redeclare package Medium = Modelica.Media.Water.StandardWater;
 
   //obtained from Modelica ValveLinear
  Modelica.Blocks.Interfaces.RealInput input_position(min = 0, max = 1) "=1: completely open, =0: completely closed";

  inner Modelica.Fluid.System system annotation(
    Placement(visible = true, transformation(origin = {-70, 70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  SCFM = path.solveSCFM(AirValvePos=input_position, engineRPM=RPM);
  RPM = path.solveRPM(SCFM);

end Intake;

solveSCFM looks like this:

Code:


function solveSCFM
  extends BaseClasses.Capacity_partial(AirValvePos=Pos);
 
  input Real Pos;
  input Real engineRPM;
  output Real capacity;
 
protected
  parameter Real AmbientTemp = 20 "Ambient temperature in degrees C";
 
algorithm
  capacity := formula with AmbientTemp and engineRPM;

end solveSCFM;

Apr-07-21 01:57:29
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Yes please, a chat would be great. Please let me know when you are available. I am available anytime in the next 2 hours if that is convenient for you.

Apr-07-21 01:46:19
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Hi, good to know and good idea. Could you please direct me to configuration instructions if you have any? I will try and get that setup running. Thank you very much for all your help.

Apr-07-21 01:12:05
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Hi, of course.

I have a server running on a raspberry pi whose job is to simulate the values of a physical system. EnginecoolantTEMP is a node whose value fluctuates as per the server's control to simulate the readings of a sensor. The goal is to have my OM model read this node value as an input and react according to the value the model reads. For instance, if enginecoolantTEMP is really big, have the model perform action A; or, if enginecoolantTEMP is really small, perform action B.

Is this kind of communication possible?

Thanks

Apr-06-21 23:02:55
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Thank you - runtime error has been fixed. Could you please explain how I might import a server node value (for example, the value of enginecoolantTEMP) into the model simulation (like as the variable coolantTEMP)? I understand how the python script communicates with the server but I am having trouble understanding how the OM model actually works/communicates with the python script.

Many thanks

Apr-06-21 21:21:06
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Ah yes, thank you for clarifying; I have been printing out node values from my python script. See below (code based on this forum discussion).

OM model:

Code:


model PlotTest
  input Real RPM;
  input Real coolantTEMP;
  Real plotting;
equation
  plotting = RPM*(1+(1/coolantTEMP)); // equation just for test purposes

end PlotTest;

Python:

Code:


from opcua import Client
from opcua import ua
import time
import logging
from opcua.ua.uatypes import VariantType

# Define the URL on which the server is broadcasting
url = "opc.tcp://my.raspberrypi.ip.address:4840/"

if __name__ == "__main__":
    client = Client(url)
    logging.basicConfig(level=logging.WARN)

    try:
        client.set_user("username")
        client.set_password("password")
        client.connect()
        print("Client connected!")

        # Set default value for RPM node. This node is set manually by a user
        engineRPM_command = client.get_node("ns=4;s=engineRPM_command")
        engineRPM_command.set_value(800, VariantType.Int32)
        RPM = engineRPM_command.get_value()
        print("Current state of engineRPM_command : {}".format(RPM))

        # Read-only node. The value is set by my server every n seconds
        enginecoolantTEMP = client.get_node("ns=4;s=current_100021")
        print("Current state of enginecoolantTEMP : {}".format(enginecoolantTEMP.get_value()))

        while (True):
            engineRPM_command.set_value(int(1.1*RPM), VariantType.Int32)
            RPM = engineRPM_command.get_value()

            coolantTEMP = enginecoolantTEMP.get_value()
           
            print("RPM value is: ", RPM)
            print("coolantTEMP value is: ", coolantTEMP)
            time.sleep(2)
            print("="*40)

    except KeyboardInterrupt:
        print("Stopping sequence!")

    finally:
        print("Done!")
        client.disconnect()

This is the OMShell output. This particular model is failing to build, but I have had success with other models (like the bouncing ball model and a simple ODE model).

Code:


>>loadModel(Modelica)
true

>>loadFile("PlotTest.mo")
true

>>simulate(PlotTest, startTime = 0, stopTime = 100, simflags = "-rt=1.0 -embeddedServer=opc-ua")
record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 100.0, numberOfIntervals = 500, tolerance = 1e-006, method = 'dassl', fileNamePrefix = 'PlotTest', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-rt=1.0 -embeddedServer=opc-ua'",
    messages = "Failed to build model: PlotTest",
    timeFrontend = 0.4598676,
    timeBackend = 0.0018066,
    timeSimCode = 0.0005407,
    timeTemplates = 0.0216975,
    timeCompile = 0.0011373,
    timeSimulation = 0.0,
    timeTotal = 0.4850643
end SimulationResult;

For the models that did work, though, I was able to open the

Code:

res.mat

file in OMEdit, like you instructed. I'm confused as to how I can grab the server values for the OM model (ie. use

Code:

engineRPM_command.get_value()

as an input to my model)

Thanks

Apr-06-21 18:25:04
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Hi SudhakarK, thank you for your response and instructions.

Can you please clarify what you mean in step 5:

You can print some values from the OpenModelica Model in your client script to check that the client can talk to the server.

When executing the python script, I am successfully reading/printing values from my pi server (as part of the python script), but I feel like I'm missing some connection between simulating the OM model and running the script.

Cheers

Apr-05-21 19:08:17
​There is a process running in OpenModelica, and I am trying to control the parameters of this...

Hello,

I am a new user of OpenModelica and I am hoping to replicate the above communication between OMEdit and my own opc-ua client. I have a python file that connects and communicates with the client and I have added the following simulation flag, as instructed from this discussion:

Code:

Additional Simulation Flags (Optional): -rt 1.0 -embeddedServer opc-ua

This simulation flag opens up an Interactive Plot, but how does the Modelica model connect to the client specified in the python code and read values for plotting?

Thanks in advance.

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