Changes between Version 17 and Version 18 of Configuration
- Timestamp:
- 09/12/13 12:23:50 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Configuration
v17 v18 1 1 = MUSCLE configuration file = 2 2 3 The MUSCLE configuration file, or historically, the [[http://www.complex-automata.org/|Complex Automata]] (CxA) file specifies what code will be used in a simulation, and how its coupled together. It is actually a Ruby file, so any Ruby syntax will work inside it.3 MUSCLE has a renewed configuration syntax, but the [wiki:Configuration2 old syntax] can still be used. The MUSCLE configuration file, or historically, the [[http://www.complex-automata.org/|Complex Automata]] (CxA) file specifies what code will be used in a simulation, and how its coupled together. It is actually a Ruby file, so any Ruby syntax will work inside it. 4 4 5 To use it, make a file a nd get the cxa object5 To use it, make a file add kernels to it by giving a name and a Java class that has the submodel implementation 6 6 {{{ 7 cxa = Cxa.LAST 8 }}} 9 and then add kernels to it by giving a name and a Java class that has the submodel implementation 10 {{{ 11 cxa.add_kernel('w', 'examples.simplejava.Sender') 12 cxa.add_kernel('r', 'examples.simplejava.ConsoleWriter') 7 w = Instance.new('w', 'examples.simplejava.Sender') 8 r = Instance.new('r', 'examples.simplejava.ConsoleWriter') 13 9 }}} 14 10 When using a C++ kernel without a Java interface, use the {{{muscle.core.standalone.NativeKernel}}} package. For an MPI executable, on a machine where mpiexec/mpirun can be called directly, use {{{muscle.core.standalone.MPIKernel}}}. 15 11 16 To add properties, add them to the {{{env}}} hash of {{{cxa}}}:12 To add properties, add them to the global {{{$env}}} hash or to the instances directly: 17 13 {{{ 18 cxa.env["max_timesteps"] = 4 19 cxa.env["w:dt"] = 1 20 cxa.env["w:someDoubleProperty"] = 6.1 21 cxa.env["w:someOtherProperty"] = "this is w text" 22 cxa.env["r:someOtherProperty"] = "this is r text" 23 cxa.env["cxa_path"] = File.dirname(__FILE__) 14 $env['max_timesteps'] = 4 15 w['dt'] = 1 16 w['someDoubleProperty'] = 6.1 17 w['someOtherProperty'] = "this is w text" 18 r['someOtherProperty'] = "this is r text" 24 19 }}} 25 20 Properties that are only meant for a single submodel are prepended with the name and a colon (e.g., {{{"submodelName:propertyName"}}}). Other properties are global and will be used by all submodels. 26 21 27 The scale of the submodels can also be specified in the CxA file. For the timestep of a submodel, use {{{" submodelName:dt"}}}, for the total time it will run, {{{"submodelName:T"}}}. For the first 3 spatial dimensions, use {{{dx}}}, {{{dy}}}, {{{dz}}} as step size, and {{{X}}}, {{{Y}}}, {{{Z}}} as total size. In Java, the scale can be accessed with the {{{getScale()}}} method of a submodel.22 The scale of the submodels can also be specified in the CxA file. For the timestep of a submodel, use {{{"dt"}}}, for the total time it will run, {{{"T"}}}. For the first 3 spatial dimensions, use {{{dx}}}, {{{dy}}}, {{{dz}}} as step size, and {{{X}}}, {{{Y}}}, {{{Z}}} as total size. In Java, the scale can be accessed with the {{{getScale()}}} method of a submodel. 28 23 29 The {{{cs}}} property of {{{cxa}}} is the connection scheme; it defines how submodels are coupled.In the example, submodel w is attached to submodel {{{r}}} by tying the conduit entrance {{{dataOut}}} of {{{w}}} to the conduit exit {{{dataIn}}} of {{{r}}}. It also ties conduit entrance {{{otherOut}}} of {{{w}}} to {{{other}}} of {{{r}}}.24 In the example, submodel w is attached to submodel {{{r}}} by tying the conduit entrance {{{dataOut}}} of {{{w}}} to the conduit exit {{{dataIn}}} of {{{r}}}. It also ties conduit entrance {{{otherOut}}} of {{{w}}} to {{{other}}} of {{{r}}}. 30 25 31 26 {{{ 32 cs = cxa.cs 33 34 cs.attach('w' => 'r') { 35 tie('dataOut', 'dataIn') 36 tie('otherOut', 'other') 37 } 27 w.couple(r, {'dataOut' => 'dataIn', 'otherOut' => 'other'}) 38 28 }}} 39 29 If the conduit entrance and exit have the same name, the second argument of {{{tie}}} is optional. … … 43 33 For native executables that uses the MUSCLE API, the following parameters may be set: {{{"submodelName:command"}}} to set the path to the executable; and {{{"submodelName:args"}}} to give additional command-line parameters to the executable. Suppose my executable is somewhere in my home {{{bin}}} directory, this could be 44 34 {{{ 45 cxa.env["subA:command"] = ENV['HOME'] + "/bin/subA"46 cxa.env["subA:args"] = "paramA paramB"35 subA["command"] = ENV['HOME'] + "/bin/subA" 36 subA["args"] = "paramA paramB" 47 37 }}} 48 38 49 For MPI code, two additional parameters should be set: {{{" submodelName:mpiexec_command"}}} with the name or the path the the mpiexec/mpirun executable; and {{{"submodelName:mpiexec_args"}}} which are the arguments, like "-np 2", etc.39 For MPI code, two additional parameters should be set: {{{"mpiexec_command"}}} with the name or the path the the mpiexec/mpirun executable; and {{{"mpiexec_args"}}} which are the arguments, like "-np 2", etc. 50 40 51 41 … … 54 44 If a conduit filter should be applied to a conduit, these can be added as a list as the last argument of {{{tie()}}}: 55 45 {{{ 56 cs.attach('w' => 'r') { 57 tie('dataOut', 'dataIn',['muscle.core.conduit.filter.MultiplyDoubleFilter_0.5']) 58 } 46 w.couple(r, {'dataOut' => 'dataIn'}, ['muscle.core.conduit.filter.MultiplyDoubleFilter_0.5']) 59 47 }}} 60 48 In the example, the MUSCLE filter {{{MultiplyDoubleFilter}}} is applied, which multiplies each double with a value, in this case 0.5. For user defined filters, one double argument may be given, separated from the class name by an underscore. MUSCLE supplies some filters in package {{{muscle.core.conduit.filter}}}: … … 80 68 For convenience, the MUSCLE filters may be referred to by their name instead of their class: 81 69 {{{ 82 cs.attach('w' => 'r') { 83 tie('dataOut', 'dataIn',['multiply_0.5','console']) 84 } 70 w.couple(r, {'dataOut' => 'dataIn'}, ['multiply_0.5','console']) 85 71 }}} 86 72 87 By default, the conduit filters get applied at the receiving submodel. If a filter should be applied at the sending submodel or if filters should be applied at both locations, the {{{ tie}}} function takes an additional argument, so that the first list of filters is applied at the sending side and the second list of filters is applied at the receiving side.73 By default, the conduit filters get applied at the receiving submodel. If a filter should be applied at the sending submodel or if filters should be applied at both locations, the {{{couple}}} function takes an additional argument, so that the first list of filters is applied at the sending side and the second list of filters is applied at the receiving side. 88 74 The following fragment multiplies the data with a constant on the sending side, and prints it on the receiving side: 89 75 {{{ 90 cs.attach('w' => 'r') { 91 tie('dataOut', 'dataIn',['multiply_0.5'],['console']) 92 } 76 w.couple(r, {'dataOut' => 'dataIn'}, ['multiply_0.5'], ['console']) 93 77 }}} 94 78 95 79 And the following fragment compresses data on the sending side and uncompresses it on the receiving side: 96 80 {{{ 97 cs.attach('w' => 'r') { 98 tie('dataOut', 'dataIn',['serialize','compress'],['decompress','deserialize']) 99 } 81 w.couple(r, {'dataOut' => 'dataIn'}, ['serialize','compress'], ['decompress','deserialize']) 100 82 }}} 101 83 102 84 For large data sets it may increase performance to split the data into multiple chunks before compressing. In the following configuration, it gets sent in separate chunks and compressing is done in a separate thread from sending: 103 85 {{{ 104 cs.attach('w' => 'r') { 105 tie('dataOut', 'dataIn',['serialize','chunk_16','compress','thread'],['decompress','dechunk_16','deserialize']) 106 } 86 w.couple(r, {'dataOut' => 'dataIn'}, ['serialize','chunk_16','compress','thread'], ['decompress','dechunk_16','deserialize']) 107 87 }}} 108 88 … … 112 92 113 93 {{{ 114 cxa.add_terminal('readA', 'muscle.core.conduit.terminal.DoubleFileSource')115 cxa['readA:filename'] = "/path/to/some.file"116 cxa['readA:suffix'] = 'dat'117 cxa['readA:relative'] = false118 cxa['readA:delimiter'] = ','94 readA = Terminal.new('readA', 'muscle.core.conduit.terminal.DoubleFileSource') 95 readA['filename'] = "/path/to/some.file" 96 readA['suffix'] = 'dat' 97 readA['relative'] = false 98 readA['delimiter'] = ',' 119 99 120 cs.attach('readA' => 'r') { 121 tie('dataIn') 122 } 100 readA.couple(r, 'dataIn') 123 101 }}} 124 102 Here, we're reading the file {{{/path/to/some.file.dat}}}, and the path is not relative to the runtime path of MUSCLE. The doubles in that file are delimited by commas. Finally, a terminal port takes any name of the receiving or sending end, so only one value is given to tie. For the moment, it is not possible to apply filters to terminals. 125 103 126 104 [[Documentation|<< Back to Documentation]] 127 128 [[Configuration2|New configuration format]]