15 import java.io.IOException;
17 import org.apache.commons.math.linear.Array2DRowRealMatrix;
18 import org.apache.commons.math.linear.RealMatrix;
19 import org.apache.commons.math.ode.DerivativeException;
20 import org.apache.commons.math.ode.FirstOrderIntegrator;
21 import org.apache.commons.math.ode.nonstiff.EulerIntegrator;
22 import org.apache.commons.math.ode.sampling.FixedStepHandler;
23 import org.apache.commons.math.ode.sampling.StepNormalizer;
45 private double[] times;
48 private RealMatrix output;
50 private double dt = .1;
54 if (mu == null &&
params != null) {
55 throw new KerMorException(
"Simulation without a parameter when parameters are configured are not allowed.");
58 double[] out =
new double[system.getDimension()];
62 this.system.setConfig(mu, input);
65 integrator.integrate(
system, 0, system.x0.evaluate(mu), T, out);
66 }
catch (Exception e) {
67 throw new KerMorException(
"Simulation failed due to an exception:" + e.getMessage(), e);
72 return output.getData();
76 double[][] dof_fields = converter.transformOutputToDoFs(output.getData());
81 for (
int i = 0; i < times.length; i++) {
88 throw new RuntimeException(
"Too many output fields used by current "
89 +
"SolutionFieldTypes set in RBSystem. Check your model.xml.");
91 int numDoF = dof_fields[fnumcnt].length;
92 switch (sftype.Type) {
93 case Displacement3D: {
95 for (
int nodenr = 0; nodenr < numDoF; nodenr++) {
96 d.setDisplacement(nodenr, (float) dof_fields[fnumcnt][nodenr],
97 (
float) dof_fields[fnumcnt + 1][nodenr], (float) dof_fields[fnumcnt + 2][nodenr]);
104 for (
int nodenr = 0; nodenr < numDoF; nodenr++) {
105 d.setValue(nodenr, (float) dof_fields[fnumcnt][nodenr]);
111 throw new RuntimeException(
"Invalid/unimplemented solution field type '" + sftype +
"'");
118 fnumcnt += sftype.Type.requiredDoFFields;
127 public void setT(
double value) {
129 this.times = Util.range(0, dt, T);
138 this.times = Util.range(0, dt, T);
147 super.loadOfflineData(mng);
149 String hlp = mng.getModelXMLTagValue(
"kermor_model.dt");
150 setdt(Double.parseDouble(hlp));
151 hlp = mng.getModelXMLTagValue(
"T");
152 setT(Double.parseDouble(hlp));
153 name = mng.getModelXMLAttribute(
"title");
155 params = mng.getParameters();
158 system = ReducedSystem.load(mng);
161 hlp = mng.getModelXMLTagValue(
"kermor_model.solvertype");
162 if (
"implicit".equals(hlp)) {
169 integrator.addStepHandler(
new StepNormalizer(dt,
this));
173 if (mng.xmlTagExists(
"kermor_model.outputtodof")) {
174 converter = (
IOutputToDoF) mng.loadModelClass(mng.getModelXMLTagValue(
"kermor_model.outputtodof"));
182 public void handleStep(
double t,
double[] x,
double[] xDot,
boolean isLast)
throws DerivativeException {
184 output.setColumn(cnt++, system.C.evaluate(t, x, mu));
The displacement field is a logical solution field describing displacements of geometry nodes/vertice...
int getNumDoFFields()
Returns the number of degree-of-freedom fields generated/computed by the model.
The default solution field containing an array of real values.
Represents the results of a simulation.
void handleStep(double t, double[] x, double[] xDot, boolean isLast)
FirstOrderIntegrator integrator
void simulate(double[] mu, int input)
Main reduced model class.
This class serves as base class for accessing various types of models at different locations...
A class for model parameters.
Custom exception for JKerMor related errors.
Custom implicit euler integrator class.
Interface for post-simulation output to DoF conversion.
void loadOfflineData(AModelManager mng)
FieldDescriptor[] logicalFieldTypes
The logical output fields of the model, each collecting one ore more model DoF's into a related unit...
SimulationResult getSimulationResult()
This Exception gets thrown when an error occurs regarding the functionality of the ModelManager...
Main reduced dynamical system class.
Default implementation for output to DoF conversion.
Contains information about the logical solution fields.
Base class for all JaRMoSBase models.