DOE Example#

This should give you a good starting point for using the functionalities provided by the doe package.

Define, and execute a design of experiment.#
# Import the necessary modules
from msolve import *
from msolve.doe import *

# Create your model
model = Model(output= "doe_example",
              name  = "model")

ground = Part(ground=True)
global_frame = Marker(label="global_frame", part=ground)
Units(force="NEWTON", mass="KILOGRAM", length="MILLIMETER", time="SECOND")
Accgrav(igrav=0, jgrav=0, kgrav=-9810)
part1 = Part(id=2, cm=Marker(qp=[0,0,-5]), ip=[1e3, 1e3, 1e3], name="part_1")
H3dOutput(save=True)
sphere = Sphere (cm=part1.cm, radius=200)

spdp = SpringDamper(type='TRANSLATION',
                    c=0.1,
                    length=20,
                    i=global_frame,
                    j=part1.cm,
                    name="spdp")

# DOEs require a simulation event to be defined that describes what type of
# simulation you want to execute.
event = SimulationEvent(type='TRANSIENT', end=1.0, dtout=0.01, store=True, returnResults=True)

# Define design variable(s) that will be modified during the Design Of Experiment
dv1 = Dv(name   = 'part_mass',
         b      = 4,
         blimit = (1, 15),
         )
part1.mass = dv1

dv2 = Dv(name   = 'spring_stiffness',
         b      = 10,
         blimit = (1,30),
        )
spdp.k = dv2

# Define response(s) that will be calculated during the Design Of Experiment
resp1 = MaxVal(function = f"DM({part1.cm.id})",
               name     = "max_elongation",
              )

# Define the experiement
experiment = DesignExperiment(model       = model,
                              design_type = 'lhs',
                              parameters  = [dv1, dv2],
                              responses   = [resp1],
                              samples     = 5,
                              )

# Run the DOE. MotionSolve will simulate all SimulationEvent(s) n-times, where
# n = total number of experiements
experiment.run(mode='ST')

# Plot the maximum elongation of the spring
experiment.plot(x="part_mass", y="spring_stiffness", z="max_elongation")