int main() { Assimilation<3,1>::Model lorenz( [] (Assimilation<3,1>::ModelState &S) { const double dt = 0.01; auto ddx = 10.0*(S[1]-S[0]); auto ddy = S[0]*(28.0-S[2])-S[1]; auto ddz = S[0]*S[1] - 8.0*S[2]/3.0; S[0] += ddx*dt; S[1] += ddy*dt; S[2] += ddz*dt; } ); Assimilation<3,1>::ObservationOp H( [](Assimilation<3,1>::ModelState &S)->Assimilation<3,1>::Observation { Assimilation<3,1>::Observation result; result[0] = S[0]; return(result); } ); Assimilation<3,1>::ModelState myV; myV[0] = ceres::Jet<double,3>(10.3, 0); myV[1] = ceres::Jet<double,3>(8.91, 1); myV[2] = ceres::Jet<double,3>(30.8, 2); lorenz(myV); // myV[1] = myV[0]*3.9 + myV[1]*myV[1]; std::cout << myV[0] << std::endl; std::cout << myV[1] << std::endl; std::cout << myV[2] << std::endl; return(0); }
data_type generate_data( void ) { data_type data; state_type x {{ 10.0 , 10.0 , 10.0 }}; state_type dxdt; double dt = 0.1; stepper_type stepper; for( double t = 0.0 ; t<100.0 ; t+= dt ) { lorenz( x , dxdt , t ); data.first.push_back( x ); data.second.push_back( dxdt ); stepper.do_step( lorenz , x , dxdt , t , dt ); } return data; }
/* * Display the scene */ void display() { // Lorenz dat shit lorenz(); // Clear the image glClear(GL_COLOR_BUFFER_BIT); // Reset previous transforms glLoadIdentity(); // Set view angle glRotated(ph,1,0,0); glRotated(th,0,1,0); int i; glBegin(GL_LINE_STRIP); for (i=0;i<N;i++) { glColor3dv(pa[i]); glVertex3dv(pa[i]); } glEnd(); // Draw axes in white glColor3f(1,1,1); glBegin(GL_LINES); glVertex3d(0,0,0); glVertex3d(1,0,0); glVertex3d(0,0,0); glVertex3d(0,1,0); glVertex3d(0,0,0); glVertex3d(0,0,1); glEnd(); // Label axes glRasterPos3d(1,0,0); Print("X"); glRasterPos3d(0,1,0); Print("Y"); glRasterPos3d(0,0,1); Print("Z"); // Display parameters glWindowPos2i(5,5); Print("View Angle=%d,%d",th,ph); // Flush and swap glFlush(); glutSwapBuffers(); }
inline void do_step( const double dt ) { rk54ck_step( lorenz() , m_x , m_t , dt , m_x_err ); }
static void lorenz_fun(void* data, float* out, float t, const float* in) { (void)data; (void)t; lorenz(out, in, 10., 28., 8. / 3.); }
inline void do_step( const double dt ) { rk4_step( lorenz() , m_x , m_t , dt ); }
inline void do_step( const double dt ) { m_stepper.do_step( lorenz(), m_x , m_t , dt ); }