Hi. I do not personally use this part of the library. Thus, only suggesting the obvious: Did you read the user guide, and the examples that are part of the test suite (in order to be sure that everything is coded correctly)? If so, the next step would be to try and devise a minimal (simplified) example, in the form of a Junit tests to be added to the test suite.
Best regards, Gilles Le sam. 11 janv. 2020 à 22:15, Bo Johnson <[email protected]> a écrit : > > Hi there, > > I'm new to Java and working on a project to integrate some ODEs. I'm > having issues knowing how to work with the event handler. My ODE class > looks like: > > public class DipoleODEimplements FirstOrderDifferentialEquations { > > public int getDimension() { > return 6; } > > public void computeDerivatives(double t, double[] y, double[] yDot) { > double r = y[0]; double r2 = r * r; double r3 = r2 * r; double r4 = > r3 * r; double theta = y[1]; double phi = y[2]; double sin_phi = > Math.sin(phi); double cos_phi = Math.cos(phi); double pr = y[3]; double > ptheta = y[4]; double ptheta2 = ptheta * ptheta; double pphi = y[5]; double > cos2 = Math.cos(phi -2 * theta); double sin2 = Math.sin(phi -2 * theta); > yDot[0] = pr; yDot[1] = ptheta / r2; yDot[2] =10 * pphi; yDot[3] = ptheta2 / > r3 - (cos_phi +3 * cos2) / (4 * r4); yDot[4] = sin2 / (2 * r3); yDot[5] = > -(sin_phi +3 * sin2) / (12 * r3); } > > } > > When the y[0] value gets below 1.0, I'd like to change the y[3] value > and the continue the integration. Basically I'm looking for a ball to > bounce off another one. The integration gets stuck though and I can't > seem to get things bouncing. Here's my event handler, too: > > EventHandler handler =new EventHandler() { > @Override public void init(double t0, double[] y0, double t) { > > } > > @Override public double g(double t, double[] y) { > return y[0] -1.0; } > > @Override public ActioneventOccurred(double t, double[] y, boolean > increasing) { > return Action.RESET_STATE; } > > @Override public void resetState(double t, double[] y) { > y[3] *= -1.0; } > }; > > And adding it to the integrator: > > dp853.addEventHandler(handler, 50.0, 1e-6, 100); > > Thanks for the help, > > -- > Bo Johnson > (801) 503-2043 > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
