Experiments
This document describes how to create experiments to perform model calibrations (using CalibrationModel.calibrate), to simulate experiments (using [SimulationModel.simulateExperiments][micromechanical.models.model.SimulationModel.simulateExperiments]), and to visualize the experiments and simulations (using VisualizationModel.plotof, VisualizationModel.plotExperiments, VisualizationModel.plotSimulations, and VisualizationModel.plotComparisons).
Create an experiment
First, we need to create an Experiment object:
from micromechanical import Experiment
experiment = Experiment(name="experiment-name", lines={}, phases={}, options=dict(e0=0.6), notes=dict(p0=100))
Here, name
is the name of the experiment, lines
is a dictionary of the measured lines for the experiment, phases
is a dictionary of the loading phases for the experiment, options
is a dictionary of the options for the experiment which is described in Calculation Options, and notes
is a dictionary of the notes for the experiment which can be used as placeholders in the label
argument of the VisualizationModel.plotof method (as well as VisualizationModel.plotExperiments, VisualizationModel.plotSimulations, and VisualizationModel.plotComparisons methods that are wrappers of the plotof
method) in addition to the options
dictionary. lines
and phases
will be added later.
Add lines to the experiment
To add a line to the experiment, we need to create a Line object and add it to the experiment:
from micromechanical import Line
experiment.lines["line-name"] = Line(x="-p", y="q", xdata=[0, 1, 2], ydata=[0, 1, 2])
Here x
and y
are the variables for the x-axis and y-axis that can be accessed from the simulation results by the SVExporter.get method, xdata
and ydata
are the data points for the line.
Add loading phases to the experiment
We can use methods for the Experiment object to add loading phases to the experiment, for example:
experiment.addIsotropicPhase(sigc=-100.0, steps=10)
experiment.addDrainedTriaxialPhase(sigc=-100, epsa_max=-0.3, steps=2000)
Add the experiment to the model
The experiment can be added to the Model object, after which the experiments in the model will be used by default in the methods for calibrations/simulations/visualizations if the experiments
argument is not provided.
from micromechanical import Model
model = Model("CH-OSIMSAND")
model.experiments["experiment-name"] = experiment
Save experiments to a file
We can use the [ExperimentModel.saveExperiments][micromechanical.models.model.ExperimentModel.saveExperiments] method to save the experiments to a JSON file:
After that, we can load the experiments from the file using the [ExperimentModel.loadExperiments][micromechanical.models.model.ExperimentModel.loadExperiments] method: