Giter Site home page Giter Site logo

marcusfuchs / modelicainaction Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mbonvini/modelicainaction

0.0 1.0 0.0 751 KB

Modelica In Action

Home Page: http://marcobonvini.com/modelica/2017/01/02/modelica-in-action.html

License: MIT License

Makefile 0.44% Jupyter Notebook 95.72% Modelica 3.84%

modelicainaction's Introduction

Modelica In Action

This repository contains examples that demonstrate how to create, compile and simulate Modelica models using JModelica.org.

Notes

All the make commands mentioned in this guide reference the Makefile located in the root directory of this repository.

Installation

In order to simplify your life the repository contains all the code necessary to create a Docker container that runs JModelica.org. In case you wonder what's a Docker container

Docker containers wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries โ€“ anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment (see https://www.docker.com/what-docker for more info).

In this case I created a "recipe", also known as Docker file, that describes how to build a container with installed everything that's needed to work with JModelica.org.

Once created and started, the container and your computer will interact as shown in the following image.

alt tag

Upon start, some folders included in this repository will be shared with the container, in the meantime the container runs an IPython server. The container exposes the port used by the IPython server to your local machine. In this way you can connect to the IPython server in the container with a browser. Once you access the IPython server you can start working with JModelica.org.

The Docker container is based on a so called image (something similar to a snapshot of a virtual machine). To create the image you have two options

  • manually build the image with the command make build-image

  • download the image with the command make download-image

The second option is preferable because it doesn't require you to wait while Docker compiles from source JModelica.org and all its dependencies.

You can verify that the container image has been built (or downloaded) using the command docker images. In my case when I run the command I see

$ docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
modelicainaction/jmodelica   1.0                 adcc4c39b0d6        1 hour ago          2.698 GB
ubuntu                       16.04               f753707788c5        8 weeks ago         127.2 MB

Starting the container

Once the container image has been created we can start it. To start the container run the command make start. This command starts the container with installed JModelica.org and an IPython notebook server listening on port 8888. The same port used by the IPython server is exposed by the container and redirected to the localhost. This means that if you open a browser and go to http://127.0.0.1:8888 you should see something like this

alt tag

By default the container is configured to share the following folders

  • modelica - a folder containing the source code of the Modelica models used in the examples

  • ipynotebooks - a folder containing the ipython notebooks with examples

Every Modelica model located in the folder modelica will be immediately visible to JModelica.org. The same is true for the folder ipynotebooks, every notebook it contains will be automatically visible when you open the browser and go to http://127.0.0.1:8888.

You can verify that the container is running with the command docker ps -a

$ docker ps -a
CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS                      NAMES
639bd33a27fb        modelicainaction/jmodelica:1.0   "sh -c 'ipython noteb"   4 hours ago         Up 4 hours          127.0.0.1:8888->8888/tcp   prickly_mayer

and you can stop and remove the container (not the container image) with the command docker stop 639bd33a27fb && docker rm 639bd33a27fb where 639bd33a27fb is the container id.

modelicainaction's People

Contributors

mbonvini avatar tbeu avatar

Watchers

 avatar

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.