# Code generation¶

class PyMbs.Input.MbsSystem.GenCode(world)

Class that provides functions to write source code of the obtained equations of motion for various languages

C(modelname, dirname='.', **kwargs)

After the equations of motion have been generated, the simulation code for C can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String.) – Directory where the model shall be exported to pymbs_wrapper (Bool) – Set to True to write python wrapper as well sfunction (Bool) – Generate s-function for Matlab-Simulink include_visual (Bool) – Generate code for visualisation
FMU(modelname, dirname='.', compile=True, **kwargs)

Deprecated since version 0.2.2: Currently the FMU-Writer is not working. All the code is still in place, but we are unable to maintain it at the moment. If this functionality would be useful to you, and you are willing to improve/maintain it, feel free to get in touch.

After the equations of motion have been generated, the simulation code for FMU can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String.) – Directory where the model shall be exported to compile (Boolean.) – If a binary of the model shall be created. Compillation is done by gcc which has to be in PATH util_folder_path (String) – Path to FMU templates and includes
Fortran90(modelname, dirname='.', **kwargs)

After the equations of motion have been generated, the simulation code for Fortran can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String.) – Directory where the model shall be exported to pymbs_wrapper (Bool) – Export python wrapper as well
Matlab(modelname, dirname='.', symbolic_mode=False)

After the equations of motion have been generated, the simulation code for Matlab can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String.) – Directory where the model shall be exported to symbolic_mode (Boolean.) – If symbolic_mode is True, code for the symbolic toolbox will be written
Modelica(modelname, dirname='.', inputsAsInputs=True, genVisualFile=None, **kwargs)

After the equations of motion have been generated, the simulation code for Modelica can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String) – Directory where the model shall be exported to genVisualFile (String) – Name of the Visual File; if no name is supplied, no visual file is generated inputsAsInputs (Bool) – Missing package (String) – Package name
Python(modelname, dirname='.')

After the equations of motion have been generated, the simulation code for Python can be generated with this function.

Parameters: modelname (String) – Name of the model - will be used as a filename at least dirname (String.) – Directory where the model shall be exported to