Git Product home page Git Product logo

seanpm2001 / learn-modelica Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 262 KB

A repository for showcasing my knowledge of the Modelica programming language, and continuing to learn the language.

Home Page: https://github.com/seanpm2001/Learn/

License: GNU General Public License v3.0

Modelica 95.57% Motoko 4.43%
article education gpl3 gplv3 learn md mo modelica seanpm2001 seanpm2001-education seanpm2001-life-archive txt learn-modelica learn-modelica-lang learn-modelica-language modelica-collection modelica-lang modelica-language

learn-modelica's Introduction


/Modelica1.png

Learning Modelica

I am not too experienced with Modelica at the moment. This document will go over my knowledge of the Modelica language so far.

This document used various version 3.4 of the Modelica programming language.

Comments in Modelica

Comments in Modelica are unique, but still easy to do.

// This is a single line comment in Modelica
// Modelica doesn't support multi-line comments as far as I know.

This example works with every version of Modelica, except for some versions of OpenModelica.

/!\ This example has not been tested yet, and may not work

Break keyword in Modelica

Modelica supports the break keyword.

break

To this day, I am still not entirely sure what the break keyword does, but most languages support it.

/!\ This example has not been tested yet, and may not work

Hello World in Modelica

A hello world program in Modelica is a bit more complicated than a Python or Perl Hello World program, but it isn't very difficult either. It is not similar to any language I am currently familiar with.

model HelloWorld "Hello World";
end HelloWorld

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Real variables in Modelica

I think this is how you implement real variables in Modelica

model isReal
	Real x "Real variable"
	Real y "Another Real variable"
end isReal

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Constant Real variables in Modelica

I think this is how you implement const. real variables in Modelica

model isConstReal
	constant Real z = -2.0 "Constant variable is negative 2";
end isConstReal

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Real parameters in Modelica

I think this is how you implement real parameter variables in Modelica

model isRealParam
	parameter Real x_start = 5.0 "The initial value of variable x";
end isConstReal

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Equations in Modelica

Modelica seems to support equations as a form of programming. This is how I make it out so far:

model equationModel
initial equation
// Define initial equation instructions
	x = x_start;
equation
	// Write the equations here...
	der(x) = a*x;
end equationModel;

I think der stands for deritative but I am not sure.

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Booleans in Modelica

Modelica supports Booleans, but not implicitely (not as a keyword)

model bcbool
b = true;
c = false;
end bcbool

This example works with every version of Modelica (as far as I know)

/!\ This example has not been tested yet, and may not work

Source

The majority of my Modelica knowledge comes from self-experimentation, and Wikipedia. Most of the examples here were dissected from ModelicaInAction by GitHub user mbonvini full credits are listed here

The majority of dissections were done from this file:

HelloWorld.mo

model HelloWorld  "The simplest differential equation ever"
 Real x "The unknown variable";
 constant Real a = -2.0 "Constant that characterizes the model";
 parameter Real x_start = 5.0 "Initial value of the variable x";
initial equation
 // Define initial conditions here...
 x = x_start;
equation
 // Write the equations here...
 der(x) = a*x;
end HelloWorld;

Other knowledge of Modelica

  1. Modelica is a curly bracket language, and it does use semicolons at the end of each line.;

  2. Modelica uses the *.mo file extension for normal use.

  3. Modelica is a software modeling language

  4. Modelica is a language recognized by GitHub

  5. Modelica has been around since 1997

  6. Modelica may be an open source language, but I am unsure

  7. No other knowledge of Modelica at the moment.


File version: 1 (2022, Monday, April 18th at 5:28 pm PST)


learn-modelica's People

Contributors

seanpm2001 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

seanwallawalla

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.