Back to Tools

MUSCLE 2 logo

 

 

 

 

The Multiscale Coupling Library and Environment (MUSCLE) couples heterogeneous computational multiscale models of multiple disciplines. Its aim is to provide a uniform platform to implement submodels using varying programming languages, execute them on heterogeneous machines and couple them across diverse networks. In addition, it considers the temporal and spatial scale at which the submodels are operating.

The library contains Java, and C and C++ APIs, allowing developers to easily use Java code or C, C++ or Fortran as a language of choice for model implementation.

Download it now at http://apps.man.poznan.pl/trac/muscle.

MUSCLE tutorial

User account: #

An user account on the grass machine (or localy) can be provided to anyone willing to execute the tutorial.

For more information, please contact: j . borgdorff at uva . nl

Assignment 1: installing and testing #

In this assignment you will download MUSCLE 1.1.1 and compile it on the grass machine.

1. Go to http://apps.man.poznan.pl/trac/muscle, there you can see the installation guide and download MUSCLE for yourself. We will not download it from the webpage, but directly on the grass machine.

2. Log in to the grass machine using the provided log-in credentials with a terminal (Linux and Mac OS X) or with PuTTY (Windows)

ssh [mschoolXX]@grass1.man.poznan.pl

Once logged in there, download and unzip muscle-1.1.1.zip.

wget apps.man.poznan.pl/trac/muscle/downloads/muscle-1.1.1.zip
unzip muscle-1.1.1.zip
cd muscle-1.1.1

you can then build it with

./build.rb all
./build.rb install -p $HOME/muscle
All prerequisites described on the installation page are already installed on the grass machine.

To add MUSCLE to the path, and set a few environment variables, run the following (don't forget the dot at the start):

. $HOME/muscle/etc/muscle.profile

3. Now you can run muscle, first showing which submodels a simple example contains:

muscle --cxa_file src/cxa/SimpleExample.cxa.rb 
This example has the MUSCLE plumber, a writer w and a reader r. The writer sends data to the reader, and the reader prints that data to screen.

You can run the simple example in the main container, by specifying --main, and specifying all submodels that should run in this container:

muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 55XX  --main plumber w r
quit with Ctrl-C, or give the flag --autoquit.

4. Take a look at all the options by running just

muscle

Assignment 2: distributed execution #

In this assignment we will do an inter-process and an inter-machine run of MUSCLE.

1. Open a second terminal, and also log in to grass1. When logged in do

. $HOME/muscle/etc/muscle.profile
cd muscle-1.1.1

Now we can run muscle on the same site. In the first terminal window, start a main container with the plumber and the writing submodel w, using your own port number. Your port numbers are 55XX and 56XX, where XX is your login number, as in mschoolXX. This is done by typing:

muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 55XX --main plumber w
What happens here?

In the second terminal, start the reading submodel r. This instance of muscle locates the one you just started by supplying its port number 55XX.

muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 55XX --mainport 55XX r
What happens?

Try now, using port 56XX in the second terminal

muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 56XX --mainport 55XX r
And now? Quit by doing Ctrl-C. What does MUSCLE in terminal 1 say?

2. In the second terminal, now log in to grass2

ssh mschoolXX@grass2
. $HOME/muscle/etc/muscle.profile
cd muscle-1.1.1
We will perform the same experiment, but now on different hosts. So on grass1, for instance run only plumber
muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 55XX --main plumber

On grass2, we now also need to specify which host the other MUSCLE instance is running on

muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 56XX --mainport 55XX --mainhost grass1 w r
Quit with Ctrl-C. What is the output in grass1? And in grass2?

Related: inter-cluster executions can be done with the --intercluster tag, with which the MUSCLE transport overlay (MTO) is used. We will not be doing this directly, because we have only one cluster arranged. In the QCG tutorial this is done under the hood by QCG-Broker.

Assignment 3: modifying the example (optional) #

To start on using MUSCLE for your own applications, you can start by modifying the examples. Depending on the programming language of your application, you can start with (Java) the files in src/java/examples/simplejava or with (C++/C/Fortran) src/cpp/examples/simplecpp. The last only modifies the Sender (the submodel w) of the simple example.

1. Modify src/java/examples/simplejava/ConsoleWriter.java so that it sends a message back to Sender.java; modify Sender.java to receive this message. Test it by running

./build.rb java
./build.rb install -p $HOME/muscle
muscle --cxa_file src/cxa/SimpleExample.cxa.rb --localport 55XX --main plumber w r

Steps that you can do:

  1. Open ConsoleWriter.java
  2. Define a port field private ConduitEntrance<double[]> msgEntrance; You will use this to receive data.
  3. At the top, import the entrance with import muscle.core.ConduitEntrance;.
  4. Instantiate it in addPortals() with msgEntrance = addConduitEntrance("messages",1,double[]);
  5. send some data over it in execute by defining double[] msg = {1.0, 0.0, 1.0}; msgEntrance.send(msg);
  6. Open Sender.java
  7. Define a port field private ConduitExit<double[]> msgExit; You will use this to receive data.
  8. At the top, import the exit with import muscle.core.ConduitExit;
  9. Instantiate it in addPortals() with msgExit = addConduitExit("messages",1,double[]);
  10. Receive some data over it in execute by doing double[] msg = msgExit.send(msg);
  11. Print the data with for (double d : msg) System.out.println("Message " + d);
  12. Open the configuration file src/cxa/SimpleExample.cxa.rb
  13. Add the lines cs.attach('r' => 'w') { tie('messages', 'messages') }
  14. Build it and execute

2. Modify src/cpp/examples/simplecpp/Sender.java and Sender.cpp to receive a message from ConsoleWriter

./build.rb all
./build.rb install -p $HOME/muscle
muscle --cxa_file src/cxa/NativeExample.cxa.rb --localport 55XX --main plumber w r
1 Attachment
572529 Views
Average (1 Vote)
Comments