Skip to content

Instantly share code, notes, and snippets.

@miho
Created November 9, 2017 13:39
Show Gist options
  • Save miho/b74509ba364f334b4387f2e6ad932ff8 to your computer and use it in GitHub Desktop.
Save miho/b74509ba364f334b4387f2e6ad932ff8 to your computer and use it in GitHub Desktop.
package eu.mihosoft.vrl.user;
import eu.mihosoft.vrl.user.VectorRhsODEInterface;
/**
* Explicit Euler Method
*/
@ComponentInfo(name="VectorExplicitEuler", category="ODE")
public class VectorExplicitEuler implements java.io.Serializable {
private static final long serialVersionUID=1L;
private transient boolean stop
public void stop() {
this.stop = true
}
@OutputInfo(name="VectorTrajectory")
public VectorTrajectory run(
@ParamInfo(name="f(t,u)")
VectorRhsODEInterface f,
@ParamGroupInfo(group="Initial Values - u|true|no description")
@ParamInfo(name="u0", style="array", options="")
double[] u0,
@ParamGroupInfo(group="Interval - t|true|no description")
@ParamInfo(name="t0", options="value=0.0D")
double t0,
@ParamGroupInfo(group="Interval - t")
@ParamInfo(name="tn", options="value=1.0D")
double tn,
@ParamInfo(name="h", options="value=1e-2D")
double h,
@ParamInfo(name="Label", options="value=\"expl. Euler\"")
String label){
u0 = u0.clone()
// create new (and empty) trajectory
VectorTrajectory trajectory = new VectorTrajectory();
// check if time interval is correctly chosen by user
if(t0 > tn){
throw new IllegalArgumentException("t0 > tn is not allowed.");
// throw new RuntimeException("Error Text");
}
// add first (i.e. start) timepoint to the trajectory
trajectory.add(t0, u0);
// notation:
// we refer to t0, u0 as the current time point and its solution (that is already known)
// we refer to t, u as the next time point an its solution (that must be computed)
stop = false
// loop time steps until the current time point is the final time point
while( t0 < tn) {
if(stop) {
break;
}
// TODO
}
return trajectory;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment