JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
SimulationTest.java
Go to the documentation of this file.
1 package kermor.test;
2 
3 import static org.junit.Assert.assertTrue;
4 import static org.junit.Assert.fail;
10 
11 import org.apache.commons.math.linear.RealMatrix;
12 import org.junit.Test;
13 
14 public class SimulationTest {
15 
16  @Test
17  public void testSimulate() {
18  try {
19  FileModelManager m = new FileModelManager();
20  m.useModel("beam");
21  ReducedModel r = new ReducedModel();
22  r.loadOfflineData(m);
23 
24  r.setT(7);
25  double[] mu = r.params.getRandomParam();
26 
27  // mu[0] = 0; mu[1] = 0;
28  RealMatrix res = null;
29  r.simulate(mu, 1);
30 
31  VisualizationData v = new VisualizationData(r.getGeometry());
32  v.useResult(r.getSimulationResult());
33  v.computeVisualFeatures(new ColorGenerator());
34 
35  Plotter p = new Plotter(r.name);
36  p.plotResult(r.getTimes(), res, r);
37 
38  while (p.isVisible()) {
39  }
40 
41  // System.out.print(Util.realMatToString(res));
42 
43  assertTrue(true);
44  } catch (Exception e) {
45  e.printStackTrace();
46  fail(e.getMessage());
47  }
48  }
49 
50  // @Test
51  public void testSimulateAfflinModel() {
52  try {
53  FileModelManager m = new FileModelManager("./test");
54  m.useModel("afflinmodel");
55  ReducedModel r = new ReducedModel();
56  r.loadOfflineData(m);
57 
58  r.setT(7);
59  // double[] mu = r.params.getRandomParam();
60  double[] mu = new double[] { 0.3, 0.01, 9.81 };
61  // mu[0] = 0; mu[1] = 0;
62  r.simulate(mu, 1);
63  double[][] res = r.getOutput();
64  System.out.println(res.length + " x " + res[0].length + ", times: " + r.getTimes().length);
65 
66  Plotter p = new Plotter(r.name);
67  p.plotResult(r.getTimes(), res, r);
68 
69  while (p.isVisible()) {
70  }
71 
72  // System.out.print(Util.realMatToString(res));
73 
74  assertTrue(true);
75  } catch (Exception e) {
76  e.printStackTrace();
77  fail(e.getMessage());
78  }
79  }
80 }
Manages models loaded from the file system available via the java.io classes.
Basic methods for plotting results of dynamical sytem simulations.
Definition: Plotter.java:24
Main reduced model class.
A container class for all model visual data.
The color generator is used to produce RGBA (RGB+Alpha) values from a given array of floats...