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

Posts

Posts

Mar-08-10 01:43:55
Perceived dearth of information/wikis...
Category: Programming

Hello Adrian,

Hi, libraries should preferably be compiled using the same compiler you are using to compile OpenModelica (mingw-gcc by default). If you mix MSVC and GCC, you run into problems because they use different C runtimes.

OK, I thought of that after my post (FX: Blush!) makes sense.

It looks like 'quite a lot' is possible, what about statically linked libraries, .a's? Same strategy?

Thanks again for your knowledgeable reply, you are giving me direction.

Best regards, Paul.

Mar-07-10 12:02:17
Perceived dearth of information/wikis...
Category: Programming

Hello Adrian,

I've been a bit distracted with Exciting Things like annual accounts :-(. Back on it, have read 12.9 and got from it:-

Fom 12.9.1.1, I can use double as real, int as Integer, int as Boolean, const char * as String, int as Enumeration Type, struct as record
From 12.9.3, I can't change input parameters. That's fine.

It looks very useful, but I have some questions. 12.9.4 is where we put it all together, what isn't clear to me is:-
with what tools should an external library be compiled such that OpenModelica can link to it and functions can be resolved?
external libraries may be dependant on other libaries - how might these be defined?

For example, my widgets are held in a nice postgreSQL database for which I have provided wrapper functions to return an array of structs containing widget info plucked from the database within a date range. Hence my external library is dependant on PostgreSQL library function calls. How do I express this to Modelica?

Best regards, Paul.

Feb-22-10 20:35:33
Perceived dearth of information/wikis...
Category: Programming

Thanks for taking the trouble to reply.

I found quite a few bits&pieces by doing...

$ find . -name '*.mos' -print

I am thinking (hoping) that we are at cross purposes here. I want to write external 'C' or C++ functions (or use someone elses) declare them in modelica syntax as in Examples/ExternalLibraries.mo and compile them for calling as in Examples/ExternalLibraries.mos. I also want to be able to use them in Eclipse/OpenModelica.

I hadn't imagined there would be limitations in how I write the 'C' code. It looks like I have some bedtime reading of that document.

Best regards, Paul.

Feb-22-10 09:06:39
Perceived dearth of information/wikis...
Category: Programming

OK, not much action here :-)

I have downloaded the source for OpenModelica and had a look around.

I found ExternalLibraries.mo, ExternalLibraries.mos, ExternalFunc1.c and ExternalFunc2.c in  OpenModelica/Examples which are interesting and useful.

I want to go further than this, write my own components (or wrap someone elses) such that they can be used as components in any modelica models, such as Modelica.Electrical.Analog.Basic.Resistor r1(R=10); in dcmotor.mo in OpenModelica/Examples.

I'll have a further rummage in the source but again, any helpers or pointers in how to do this/where to look would be appreciated.

Best regards, Paul.

Feb-19-10 02:17:33
Perceived dearth of information/wikis...
Category: Programming

Hello All,

I am new to Modelica and excited by what it appears to offer. I have been trying to 'get inside' Modelica as quickly as possible and have installed OpenModelica, amongst other things.

I am interested in porting external C/C++ libraries such that they can be represented/used in Modelica simulations. Furthermore that C/C++ can be generated for these models for compilation/execution elsewhere. A quick shufti through the indexes in the books gives me Chapter 12 in  'Introduction to Physical Modeling with Modelica', but it doesn't touch what I want to know. I don't see any connection between the Modelica library and the libraries that will be linked to to run the simulation.

Please take for example the Neural Network library here here. If you download this model, you'll see a definition file NeuralNetwork.mo which is human readable and seems to contain the Modelica definitions for the Modelica environment. MathModelica can read this file and gives me a hierarchy of available components within the library. Great! Just what I wanted! However, although there is passing reference to a Dymola library I can't see the source code to which the .mo definitions refer and hence can't see how any C/C++ could be generated and run against the library.

The books I have bought seem to be focused on users of a Modelica environment rather than engineers trying to bring new functionality in terms of external libraries into the Modelica domain.

What I am trying to say is that information on how a/ write a C/C++ library or b/ port an exiting C/C++ library and create the corresponding Modelica definitions such that these components can be used in a Modelica environment (whatever that may be) is thin on the ground.

I would be so very grateful for some useful pointers here, i.e., have I missed a really good FAQ/wiki/guide/book, or site containing some simple and more complex examples of libraries and how they might be visible to a Modelica environment.

Best regards, Paul.

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