Note
Click here to download the full example code
Overview of the MockModelPersistent for load case LC1¶
A toy model for testing purpose of persistent data - mono-component version
from __future__ import annotations
from vimseo import EXAMPLE_RUNS_DIR
from vimseo.api import create_model
from vimseo.core.model_settings import IntegratedModelSettings
First, let's instantiate the model for a given load case:
model_name = "MockModelPersistent"
load_case = "LC1"
model = create_model(
model_name,
load_case,
check_subprocess=True,
model_options=IntegratedModelSettings(
directory_archive_root=EXAMPLE_RUNS_DIR / "archive/model_gallery",
directory_scratch_root=EXAMPLE_RUNS_DIR / "scratch/model_gallery",
cache_file_path=EXAMPLE_RUNS_DIR
/ f"caches/model_gallery/{model_name}_{load_case}_cache.hdf",
),
)
The model description can be accessed like this:
print(model.description)
Out:
Model MockModelPersistent: A toy model for testing purpose of persistent data - mono-component version
Load case:
Load case LC1: A first mock load case.
Boundary condition variables:
[]
Plot parameters:
{
"curves": []
}
Load:
Load(direction='', sign='', type='')
Default values:
Default geometrical variables:
{"x1": [2.0], "x2": [5.0], "x3": [1.0, 2.0, 3.0]}
Default numerical variables:
{}
Default boundary conditions variables:
{}
Default material variables:
{}
model_inputs:
[
"x1",
"x2",
"x3"
]
model_outputs:
[
"y1",
"y2",
"y3",
"y4",
"y5",
"error_code",
"model",
"load_case",
"description",
"job_name",
"persistent_result_files",
"n_cpus",
"date",
"cpu_time",
"user",
"machine",
"vims_git_version",
"directory_archive_root",
"directory_archive_job",
"directory_scratch_root",
"directory_scratch_job"
]
An illustration of the load case:
model.show_image()
The model is executed with its default input values:
model.execute()
Out:
{'x1': array([2.]), 'x2': array([5.]), 'x3': array([1., 2., 3.]), 'cpu_time': array([0.0047071]), 'date': array(['2026-03-26 14:43:29.224445'], dtype='<U26'), 'description': array([''], dtype='<U1'), 'directory_archive_job': array(['/home/sebastien.bocquet/PycharmProjects/vimseo/docs/runnable_examples/model_runs/archive/model_gallery/MockModelPersistent/LC1/2'],
dtype='<U128'), 'directory_archive_root': array(['/home/sebastien.bocquet/PycharmProjects/vimseo/docs/runnable_examples/model_runs/archive/model_gallery'],
dtype='<U102'), 'directory_scratch_job': array(['/home/sebastien.bocquet/PycharmProjects/vimseo/docs/runnable_examples/model_runs/scratch/model_gallery/MockModelPersistent/LC1/1'],
dtype='<U128'), 'directory_scratch_root': array(['/home/sebastien.bocquet/PycharmProjects/vimseo/docs/runnable_examples/model_runs/scratch/model_gallery'],
dtype='<U102'), 'error_code': array([0]), 'job_name': array([''], dtype='<U1'), 'load_case': array(['LC1'], dtype='<U3'), 'machine': array(['IPF7101'], dtype='<U7'), 'model': array(['MockModelPersistent'], dtype='<U19'), 'n_cpus': array([1]), 'persistent_result_files': array(['green_ellipse.png', 'blue_line.png'], dtype='<U17'), 'user': array(['sebastien.bocquet'], dtype='<U17'), 'vims_git_version': array(['d0050d8de498c8354552cdde540fb3e524454871'], dtype='<U40'), 'y1': 7.0, 'y2': array([1, 2, 3, 4, 5]), 'y3': array(['mock_string'], dtype='<U11'), 'y4': array([6.]), 'y5': array([ 6., 36., 216.])}
And the results are visualised with the pre-defined plots:
figures = model.plot_results(show=True)
Total running time of the script: ( 0 minutes 0.025 seconds)
Download Python source code: plot_MockModelPersistent_LC1.py
Download Jupyter notebook: plot_MockModelPersistent_LC1.ipynb