Write SIMO Task
Create a SIMO task from scratch and export as JSON.
This example demonstrates how to programmatically create a SIMO task and model with a simple body and export it to a JSON file for later use in SIMA.
Example
Basic usage of this script:
>>> python write_simo_task.py
The script generates a SIMO task file in the output/simo/ directory.
Source Code
write_simo_task.py
1"""Create a SIMO task from scratch and export as JSON.
2
3This example demonstrates how to programmatically create a SIMO task and model
4with a simple body and export it to a JSON file for later use in SIMA.
5
6Example:
7 Basic usage of this script:
8
9 >>> python write_simo_task.py
10
11 The script generates a SIMO task file in the output/simo/ directory.
12"""
13import os
14from pathlib import Path
15from simapy.sima import simo
16from simapy.sima import hydro
17
18from simapy.sima_writer import SIMAWriter
19
20
21def main():
22 task = simo.SIMOTask(name="test", model=simo.SIMOModel())
23 body = simo.SIMOBody(name="body", _type=simo.BodyType.THREE_DOF_TIME_DOMAIN)
24 body.structuralMass = hydro.StructuralMass(mass=100.0)
25
26 task.model.bodies.append(body)
27
28 file = Path("output/simo/simo_task.json")
29 os.makedirs(file.parent, exist_ok=True)
30 writer = SIMAWriter()
31 writer.write([task], file, indent=4)
32
33
34if __name__ == "__main__":
35 main()