////////////////////////// //MsgDest functions. ///////////////////////// void MarkovGslSolver::process( const Eref& e, ProcPtr info ) { double nextt = info->currTime + info->dt; double t = info->currTime; double sum = 0; for ( unsigned int i = 0; i < nVars_; ++i ) stateGsl_[i] = state_[i]; while ( t < nextt ) { int status = gsl_odeiv_evolve_apply ( gslEvolve_, gslControl_, gslStep_, &gslSys_, &t, nextt, &internalStepSize_, stateGsl_); //Simple idea borrowed from Dieter Jaeger's implementation of a Markov //channel to deal with potential round-off error. sum = 0; for ( unsigned int i = 0; i < nVars_; i++ ) sum += stateGsl_[i]; for ( unsigned int i = 0; i < nVars_; i++ ) stateGsl_[i] /= sum; if ( status != GSL_SUCCESS ) break; } for ( unsigned int i = 0; i < nVars_; ++i ) state_[i] = stateGsl_[i]; stateOut()->send( e, info->threadIndexInGroup, state_ ); }
void ht_neuron::update( Time const& origin, const long_t from, const long_t to ) { assert( to >= 0 && ( delay ) from < Scheduler::get_min_delay() ); assert( from < to ); for ( long_t lag = from; lag < to; ++lag ) { double tt = 0.0; // it's all relative! // adaptive step integration while ( tt < B_.step_ ) { const int status = gsl_odeiv_evolve_apply( B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &tt, // from t... B_.step_, // ...to t=t+h &B_.IntegrationStep_, // integration window (written on!) S_.y_ ); // neuron state if ( status != GSL_SUCCESS ) throw GSLSolverFailure( get_name(), status ); } // Deactivate potassium current after spike time have expired if ( S_.r_potassium_ && --S_.r_potassium_ == 0 ) S_.g_spike_ = false; // Deactivate potassium current. // Add new spikes to node state array for ( size_t i = 0; i < B_.spike_inputs_.size(); ++i ) S_.y_[ 2 + 2 * i ] += V_.cond_steps_[ i ] * B_.spike_inputs_[ i ].get_value( lag ); // A spike is generated when the membrane potential (V) exceeds // the threshold (Theta). if ( !S_.g_spike_ && S_.y_[ State_::VM ] >= S_.y_[ State_::THETA ] ) { // Set V and Theta to the sodium reversal potential. S_.y_[ State_::VM ] = P_.E_Na; S_.y_[ State_::THETA ] = P_.E_Na; // Activate fast potassium current. Drives the // membrane potential towards the potassium reversal // potential (activate only if duration is non-zero). S_.g_spike_ = V_.PotassiumRefractoryCounts_ > 0; S_.r_potassium_ = V_.PotassiumRefractoryCounts_; set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); SpikeEvent se; network()->send( *this, se, lag ); } // set new input current B_.I_stim_ = B_.currents_.get_value( lag ); B_.logger_.record_data( origin.get_steps() + lag ); } }
static VALUE rb_gsl_odeiv_evolve_apply(VALUE obj, VALUE cc, VALUE ss, VALUE sss, VALUE tt, VALUE tt1, VALUE hh, VALUE yy) { gsl_odeiv_evolve *e = NULL; gsl_odeiv_control *c = NULL; gsl_odeiv_step *s = NULL; gsl_odeiv_system *sys = NULL; gsl_vector *y = NULL; double t, h; int status; CHECK_STEP(ss); CHECK_SYSTEM(sss); CHECK_VECTOR(yy); Data_Get_Struct(obj, gsl_odeiv_evolve, e); if (NIL_P(cc)) { c = NULL; } else { CHECK_CONTROL(cc); Data_Get_Struct(cc, gsl_odeiv_control, c); } Data_Get_Struct(ss, gsl_odeiv_step, s); Data_Get_Struct(sss, gsl_odeiv_system, sys); Data_Get_Struct(yy, gsl_vector, y); /* if (TYPE(tt) != T_FLOAT) rb_raise(rb_eTypeError, "argument 4 Float expected"); if (TYPE(hh) != T_FLOAT) rb_raise(rb_eTypeError, "argument 6 Float expected");*/ t = NUM2DBL(tt); h = NUM2DBL(hh); status = gsl_odeiv_evolve_apply(e, c, s, sys, &t, NUM2DBL(tt1), &h, y->data); /* RFLOAT(tt)->value = t; RFLOAT(hh)->value = h;*/ return rb_ary_new3(3, rb_float_new(t), rb_float_new(h), INT2FIX(status)); }
int main(int argc, char** argv) { // Tamanho do sistema a ser resolvido size_t dim = 2; // Definicao dos erros por passo de tempo double abstol = 1.e-6; double reltol = 1.e-10; // Definindo o metodo a ser usado const gsl_odeiv_step_type* T = gsl_odeiv_step_rk8pd; // Alocando espaco para utilizar o metodo T e a dimensao do // numero de equacoes a serem resolvidas. gsl_odeiv_step* s = gsl_odeiv_step_alloc(T, dim); // Verifica e obtem o melhor passo na evolucao da variavel, de // acordo com os erros absoluto e relativo alimentados. gsl_odeiv_control* c = gsl_odeiv_control_y_new(abstol, reltol); // Alocando espaco para aplicar as operacoes de solucao numerica gsl_odeiv_evolve* e = gsl_odeiv_evolve_alloc(dim); // Definicao dos parametros usados e do sistema a ser resolvido // (funcao e seu jacobiano). double mu = 10; gsl_odeiv_system sys = {func, jac, 2, &mu}; // Definicao das variaveis e suas condicoes iniciais double t = 0.0, tf = 100.0; double h = 1e-2; double y[2] = { 1.0, 0.0 }; // C.I. das variaveis // Variaveis auxiliares int status; printf ("%.5e %.5e %.5e\n", t, y[0], y[1]); while (t < tf) { // Evolucao da funcao. // Importante!! t e h sao passados por referencia e seus valores // mudam a cada iteracao. Dessa maneira, o passo de tempo NAO eh // fixo!!! status = gsl_odeiv_evolve_apply(e, c, s, &sys, &t, tf, &h, y); if(status != GSL_SUCCESS) { printf ("error, return value=%d\n", status); break; } printf ("%.5e %.5e %.5e\n", t, y[0], y[1]); } // Desalocando a memoria... gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); return (EXIT_SUCCESS); }
void GslInternal::integrate(double t_out){ double h = 1e-6; // starting step size for ode solver std::cout << "I wanna integrate from " << t_ << " to " << t_out << std::endl; int flag = gsl_odeiv_evolve_apply (evolve_ptr, control_ptr, step_ptr, &my_system, &t_, t_out, &h, &output(INTEGRATOR_XF).data()[0]); if(flag!=GSL_SUCCESS) gsl_error("Integrate",flag); std::cout << "GSL returned succes: " << flag << std::endl; }
/* ---------------------------------------------------------------- * Update and spike handling functions * ---------------------------------------------------------------- */ void nest::hh_cond_exp_traub::update( Time const& origin, const long_t from, const long_t to ) { assert( to >= 0 && ( delay ) from < kernel().connection_builder_manager.get_min_delay() ); assert( from < to ); for ( long_t lag = from; lag < to; ++lag ) { double tt = 0.0; // it's all relative! V_.U_old_ = S_.y_[ State_::V_M ]; // adaptive step integration while ( tt < B_.step_ ) { const int status = gsl_odeiv_evolve_apply( B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &tt, // from t... B_.step_, // ...to t=t+h &B_.IntegrationStep_, // integration window (written on!) S_.y_ ); // neuron state if ( status != GSL_SUCCESS ) throw GSLSolverFailure( get_name(), status ); } S_.y_[ State_::G_EXC ] += B_.spike_exc_.get_value( lag ); S_.y_[ State_::G_INH ] += B_.spike_inh_.get_value( lag ); // sending spikes: crossing 0 mV, pseudo-refractoriness and local maximum... // refractory? if ( S_.r_ ) { --S_.r_; } else { // (threshold && maximum ) if ( S_.y_[ State_::V_M ] >= P_.V_T + 30. && V_.U_old_ > S_.y_[ State_::V_M ] ) { S_.r_ = V_.RefractoryCounts_; set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); SpikeEvent se; kernel().event_delivery_manager.send( *this, se, lag ); } } // set new input current B_.I_stim_ = B_.currents_.get_value( lag ); // log state data B_.logger_.record_data( origin.get_steps() + lag ); } }
int sys_driver (const gsl_odeiv_step_type * T, const gsl_odeiv_system * sys, double t0, double t1, double hstart, double y[], double epsabs, double epsrel, const char desc[]) { /* This function evolves a system sys with stepper T from t0 to t1. Step length is varied via error control with possibly different absolute and relative error tolerances. */ int s = 0; int steps = 0; double t = t0; double h = hstart; gsl_odeiv_step * step = gsl_odeiv_step_alloc (T, sys->dimension); gsl_odeiv_control *c = gsl_odeiv_control_standard_new (epsabs, epsrel, 1.0, 0.0); gsl_odeiv_evolve *e = gsl_odeiv_evolve_alloc (sys->dimension); while (t < t1) { s = gsl_odeiv_evolve_apply (e, c, step, sys, &t, t1, &h, y); if (s != GSL_SUCCESS) { gsl_test(s, "sys_driver: %s evolve_apply returned %d", gsl_odeiv_step_name (step), s); break; } if (steps > 1e7) { gsl_test(GSL_EMAXITER, "sys_driver: %s evolve_apply reached maxiter at t=%g", gsl_odeiv_step_name (step), t); s = GSL_EMAXITER; break; } steps++; } gsl_test(s, "%s %s [%g,%g], %d steps completed", gsl_odeiv_step_name (step), desc, t0, t1, steps); gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (step); return s; }
char finished_one_jump_all_ode(struct_all_ode *s, double t1) { int i; char ok; ok = s->time_second < t1; if (ok) { // printf("simulating from t0=%.5e to t1=%.5e\n", s->time_second, t1); } while (s->time_second < t1) { s->status = gsl_odeiv_evolve_apply(s->e, s->c, s->s, &s->sys, &s->time_second, t1, &s->h, s->x); if (s->h > s->hmax) s->h = s->hmax; if (s->status == GSL_FAILURE) { s->x[s->NX - 1] = 0; if (s->mode == MODE_FLY_TO_SOL) { if (s->print_values_fly_to_sol) { printf("passing from fly to sol at time t=%.5e\n", s->time_second); print_state(s->x, NULL); print_energies(s, s->x); } compute_fly_to_sol_percussion(s); if (s->print_values_fly_to_sol) { printf("passed from fly to sol at time t=%.5e\n", s->time_second); print_state(s->x, NULL); print_energies(s, s->x); } s->mode = MODE_SOL; } if (s->mode == MODE_SOL_TO_FLY) { if (s->print_values_sol_to_fly) { printf("passing from sol to fly at time t=%.5e\n", s->time_second); print_state(s->x, NULL); print_energies(s, s->x); } s->x[INDX_VX] = -sin(s->x[INDX_TH]) * s->x[INDX_VR]; s->x[INDX_VZ] = cos(s->x[INDX_TH]) * s->x[INDX_VR]; s->x[INDX_VR] = 0; s->x[INDX_R] = s->r0; if (s->print_values_sol_to_fly) { printf("passed from sol to fly at time t=%.5e\n", s->time_second); print_state(s->x, NULL); print_energies(s, s->x); } return 1; } } } return 0; }
/* Many good algorithms don't need the Jacobian, so we'll just pass a null pointer */ void gslode(void * mypars, double max_time, FILE *theory) { /* Create our ODE system */ gsl_odeiv_system sys = {func, NULL, DIM, mypars}; /* Range of time to simulate*/ double t = 0.0, t1 = max_time; /* Initial step size, will be modified as needed by adaptive alogorithm */ double h = 1e-6; /* initial conditions, No */ double y[DIM] = { No, 0.0 }; /* Define method as Embedded Runge-Kutta Prince-Dormand (8,9) method */ const gsl_odeiv_step_type * T = gsl_odeiv_step_rk4; // = gsl_odeiv_step_rk8pd; /* allocate stepper for our method of correct dimension*/ gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, DIM); /* control will maintain absolute and relative error */ gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-6, 0.0); /* allocate the evolver */ gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (DIM); /*dummy to make easy to switch to regular printing */ double ti = t1; int i; /* Uncomment the outer for loop to print * * Npts sample pts at regular intervals */ for (i = 1; i <= NPTS; i++){ ti = i * t1 / NPTS; while (t < ti) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y); if (status != GSL_SUCCESS) break; // fprintf(theory,"%.6e %.6e %.6e\n",t,y[0],y[1]); //adaptive mesh } fprintf(theory,"%g %g %g\n",t,y[0],y[1]); } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); }
void one_step_ode_base(struct_ode_base *s, double t1) { char ok; ok = s->time_second < t1; if (ok) { // printf("simulating from t0=%.5e to t1=%.5e\n", s->time_second, t1); } while (s->time_second < t1) { s->status = gsl_odeiv_evolve_apply(s->e, s->c, s->s, &s->sys, &s->time_second, t1, &s->h, s->x); if (s->h > s->hmax) s->h = s->hmax; if (s->status == GSL_FAILURE) { } } }
void func_fdf(double t_end, void *_par, double* f, double* df) { odesolver_t* par = (odesolver_t*) _par; // Safety check if(t_end < 0.) { fprintf(stderr, "Warning: value requested at t < 0!\n"); *f = 0.; *df = 0.; return; } while(t_end < par->points[par->cur_idx].t) par->cur_idx--; double t = par->points[par->cur_idx].t; double h = 1e-6; // xdot, ydot, x, y double y[4]; y[0] = par->points[par->cur_idx].y[0]; y[1] = par->points[par->cur_idx].y[1]; y[2] = par->points[par->cur_idx].y[2]; y[3] = par->points[par->cur_idx].y[3]; gsl_odeiv_evolve_reset(par->e); while(t < t_end) gsl_odeiv_evolve_apply(par->e, par->c, par->s, &par->sys, &t, t_end, &h, y); *f = y[2] - y[3]; *df = y[0] - y[1]; par->cur_idx++; if(par->cur_idx >= CACHE_SIZE) { fprintf(stderr, "Warning: cache size too small!\n"); par->cur_idx = CACHE_SIZE - 1; } par->points[par->cur_idx].t = t; par->points[par->cur_idx].y[0] = y[0]; par->points[par->cur_idx].y[1] = y[1]; par->points[par->cur_idx].y[2] = y[2]; par->points[par->cur_idx].y[3] = y[3]; }
int main(int argc, char** argv){ if(argc < 3){ fprintf(stderr, "%s gamma gmax\n", argv[0]); return EXIT_FAILURE; } const gsl_odeiv_step_type *T = gsl_odeiv_step_rkf45; gsl_odeiv_step *s = gsl_odeiv_step_alloc(T, 3); gsl_odeiv_control *c = gsl_odeiv_control_y_new(1e-6, 0.0); //(abs, rel) gsl_odeiv_evolve *e = gsl_odeiv_evolve_alloc(3); // 3-dimensional vdp_params par = {2, 4, atof(argv[1]), atof(argv[2]), 0, 0}; gsl_odeiv_system sys = {vdp, jac_vdp, 3, &par}; double t = 0.0; //Start at this value double t1 = 20; double interval = 0.1; double h = 1e-6; //Start at this timestep double y[3] = {1.0, 0.1, 3.0}; //Initial condition while(t < t1){ int status = gsl_odeiv_evolve_apply(e, c, s, &sys, &t, t1, &h, y); if(status != GSL_SUCCESS){ fprintf(stderr, "Could not evaluate step."); break; } // if(t > t2 + interval){ printf("%.5e %.5e %.5e %.5e\n", t, y[0], y[1], y[2]); // t2 = t; // } } //Print out data to stderr fprintf(stderr, "count: %d\n", par.count); fprintf(stderr, "jaccount: %d\n", par.jac_count); //Free up memory gsl_odeiv_evolve_free(e); gsl_odeiv_control_free(c); gsl_odeiv_step_free(s); return EXIT_SUCCESS; }
CAMLprim value ml_gsl_odeiv_evolve_apply(value e, value c, value s, value syst, value t, value t1, value h, value y) { CAMLparam5(e, c, s, syst, y); double t_c = Double_val(t); double h_c = Double_val(h); LOCALARRAY(double, y_copy, Double_array_length(y)); int status; memcpy(y_copy, Double_array_val(y), Bosize_val(y)); status = gsl_odeiv_evolve_apply(ODEIV_EVOLVE_VAL(e), ODEIV_CONTROL_VAL(c), ODEIV_STEP_VAL(s), ODEIV_SYSTEM_VAL(syst), &t_c, Double_val(t1), &h_c, y_copy); /* GSL does not call the error handler for this function */ if (status) GSL_ERROR_VAL ("gsl_odeiv_evolve_apply", status, Val_unit); memcpy(Double_array_val(y), y_copy, Bosize_val(y)); CAMLreturn(copy_two_double(t_c, h_c)); }
void integrator_Func(LALStatus *status, integrator_System *integrator, REAL8 step, REAL8 values[]) { INITSTATUS(status, "integrator_Func", INTEGRATORC); ATTATCHSTATUSPTR(status); REAL8 time = 0., time_Old, step_X = step; while (time < step) { time_Old = time; gsl_odeiv_evolve_apply(integrator->solver_evolve, integrator->solver_control, integrator->solver_step, &(integrator->solver_system), &time, step, &step_X, values); if (time == time_Old) { INT2 i; for (i = 0; i < integrator->solver_system.dimension + 1; i++) { values[i] = 0.; } ABORT(status, LALINSPIRALH_ESTOPPED, LALINSPIRALH_MSGESTOPPED); } } DETATCHSTATUSPTR(status); RETURN (status); }
static int odesys_odegsl_step (odegsl_t * odegsl, const double t1, const double t2, double *coef) { double t = t1; while (t < t2) { int ode_status = gsl_odeiv_evolve_apply (odegsl->evolve, odegsl->control, odegsl->step, &(odegsl->system), &t, t2, &(odegsl->hstep), coef); if (ode_status) { fprintf (stderr, "%s %d: gsl_odeiv_evolve_apply error: %s\n", __func__, __LINE__, gsl_strerror (ode_status)); return -1; } } return 0; }
void ode(double *params, double maxtime, double * sps) { double *y; y = sps; const gsl_odeiv_step_type *T = gsl_odeiv_step_gear2; gsl_odeiv_step *stp = gsl_odeiv_step_alloc(T, 27); gsl_odeiv_control *c = gsl_odeiv_control_y_new(1e-4, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc(27); gsl_odeiv_system sys = {func, 0, 27, params}; double t = 0.0, t1 = maxtime; double h = 1e-6; while (t < t1) { gsl_odeiv_evolve_apply (e, c, stp, &sys, &t, t1, &h, y); } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (stp); }
static VALUE rb_gsl_odeiv_solver_apply(VALUE obj, VALUE tt, VALUE tt1, VALUE hh, VALUE yy) { gsl_odeiv_solver *gos = NULL; gsl_vector *y = NULL; double t, h; int status; CHECK_VECTOR(yy); Need_Float(tt1); Data_Get_Struct(obj, gsl_odeiv_solver, gos); Data_Get_Struct(yy, gsl_vector, y); /* if (TYPE(tt) != T_FLOAT) rb_raise(rb_eTypeError, "argument 0 Float expected"); if (TYPE(hh) != T_FLOAT) rb_raise(rb_eTypeError, "argument 2 Float expected");*/ t = NUM2DBL(tt); h = NUM2DBL(hh); status = gsl_odeiv_evolve_apply(gos->e, gos->c, gos->s, gos->sys, &t, NUM2DBL(tt1), &h, y->data); /* RFLOAT(tt)->value = t; RFLOAT(hh)->value = h; return INT2FIX(status);*/ return rb_ary_new3(3, rb_float_new(t), rb_float_new(h), INT2FIX(status)); }
int main (void) { const gsl_odeiv_step_type * T = gsl_odeiv_step_rk8pd; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 2); gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-6, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (2); double mu = 10; gsl_odeiv_system sys = {func, jac, 2, &mu}; double t = 0.0, t1 = 100.0; double h = 1e-6; double y[2] = { 1.0, 0.0 }; while (t < t1) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y); if (status != GSL_SUCCESS) break; printf ("%.5e %.5e %.5e\n", t, y[0], y[1]); } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); return 0; }
void runOde(double * data, double tmax, double dt,ODEparams * pa) { const gsl_odeiv_step_type * T = gsl_odeiv_step_rk8pd; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 2); gsl_odeiv_control * c = gsl_odeiv_control_y_new (1e-10, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (2); gsl_odeiv_system sys = {func, jac, 2, pa}; int totalframe=ceil(tmax/dt); int i=0; double t1=dt,t=0.0; double h = 1e-10; double y[2] = { pa->x0,pa->y0}; while(t1<tmax) { while (t < t1) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, t1, &h, y); if (status != GSL_SUCCESS) break; } i++; t1+=dt; data[i]=y[0]; /* printf("%lf %lf\n",t1,y[0]); */ } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); }
void nest::iaf_cond_alpha::update( Time const& origin, const long from, const long to ) { assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) { double t = 0.0; // numerical integration with adaptive step size control: // ------------------------------------------------------ // gsl_odeiv_evolve_apply performs only a single numerical // integration step, starting from t and bounded by step; // the while-loop ensures integration over the whole simulation // step (0, step] if more than one integration step is needed due // to a small integration step size; // note that (t+IntegrationStep > step) leads to integration over // (t, step] and afterwards setting t to step, but it does not // enforce setting IntegrationStep to step-t; this is of advantage // for a consistent and efficient integration across subsequent // simulation intervals while ( t < B_.step_ ) { const int status = gsl_odeiv_evolve_apply( B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &t, // from t B_.step_, // to t <= step &B_.IntegrationStep_, // integration step size S_.y ); // neuronal state if ( status != GSL_SUCCESS ) { throw GSLSolverFailure( get_name(), status ); } } // refractoriness and spike generation if ( S_.r ) { // neuron is absolute refractory --S_.r; S_.y[ State_::V_M ] = P_.V_reset; // clamp potential } else // neuron is not absolute refractory if ( S_.y[ State_::V_M ] >= P_.V_th ) { S_.r = V_.RefractoryCounts; S_.y[ State_::V_M ] = P_.V_reset; // log spike with Archiving_Node set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); SpikeEvent se; kernel().event_delivery_manager.send( *this, se, lag ); } // add incoming spikes S_.y[ State_::DG_EXC ] += B_.spike_exc_.get_value( lag ) * V_.PSConInit_E; S_.y[ State_::DG_INH ] += B_.spike_inh_.get_value( lag ) * V_.PSConInit_I; // set new input current B_.I_stim_ = B_.currents_.get_value( lag ); // log state data B_.logger_.record_data( origin.get_steps() + lag ); } }
int main() { double E2=0.; double A,E,beta,te[11],Me[11],Mt[11]; int num_data; FILE *inp, *outp; inp = fopen("global.dat","r"); fscanf(inp,"%lf %lf %lf",&A,&E,&beta); /* read kinetic parameters */ beta/=60.; /* Convert heating rate to K/s */ double params[]={A,E,beta}; // read experimental data int i=0; int status; while (1){ status = fscanf(inp,"%lf %lf",&te[i],&Me[i]); if (status == EOF) break; i++; } num_data = i; fclose(inp); // integration const gsl_odeiv_step_type * T = gsl_odeiv_step_gear1; gsl_odeiv_step *s = gsl_odeiv_step_alloc(T,1); gsl_odeiv_control *c = gsl_odeiv_control_y_new(1e-6,0.0); gsl_odeiv_evolve *e = gsl_odeiv_evolve_alloc(1); gsl_odeiv_system sys = {func, NULL, 1, (void *)params}; double t = 0.1, t1 = 800.; double h = 1e-3; double M[1]; M[0]=1.; outp = fopen("global.out","w"); fprintf(outp,"Temp (K) M\n------------------\n"); i=0; double t_old=0., M_old[1]; M_old[0]=1.; while (t < t1){ int status = gsl_odeiv_evolve_apply(e, c, s, &sys, &t, t1, &h, M); if (status != GSL_SUCCESS) break; fprintf(outp,"%6.1lf %10.4lf\n",t,M[0]); if ( (t >= te[i]) && (t_old <= te[i]) ) { Mt[i] = (te[i]-t_old)*(M[0]-M_old[0])/(t-t_old) + M_old[0]; E2+=(Me[i]-Mt[i])*(Me[i]-Mt[i]); // fprintf(outp,"%i %lf %lf %lf %lf\n",i,te[i],Me[i],Mt[i],E2); i++; } t_old=t; M_old[0]=M[0]; } fprintf(outp,"For A = %g, E = %g, and beta = %.3lf\n",A,E,beta); fprintf(outp,"the sum of squared errors is %lf.",E2); gsl_odeiv_evolve_free(e); gsl_odeiv_control_free(c); gsl_odeiv_step_free(s); fclose(outp); return 0; }
double fevol_shrinker (double bisec_param, int print, char * filename, void * p) { const gsl_odeiv_step_type * T = STEPPER; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 2); gsl_odeiv_control * c = gsl_odeiv_control_y_new (STEPPER_ERROR, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (2); double dt=PRINT_DT, t_last=0.; gsl_odeiv_system sys = {func_shrinker, jac_dummy, 2, p}; double t = T0; double h = H0; double A = bisec_param; double y[2] = { A*t + ((3*A - 4*(-1 + k)*pow(A,3))*pow(2 + k,-1)*pow(t,3))/12. + (A*(15 - 40*(-1 + k)*pow(A,2) + 16*pow(A,4)*(1 - 3*k + 2*pow(k,2)))* pow(t,5)*pow(8 + 6*k + pow(k,2),-1))/160., A + ((3*A - 4*(-1 + k)*pow(A,3))*pow(2 + k,-1)*pow(t,2))/4. + (A*(15 - 40*(-1 + k)*pow(A,2) + 16*pow(A,4)*(1 - 3*k + 2*pow(k,2)))* pow(t,4)*pow(8 + 6*k + pow(k,2),-1))/32., }; FILE * file; if (print){ file = fopen(filename, "a"); fprintf(file, "# A = %.15f\n", bisec_param ); } while (t < T_MAX) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, T_MAX, &h, y); if (status != GSL_SUCCESS) break; /* are we still in the strip [0,pi]? */ if ( 0. > y[0] || y[0] > 3.15 ) break; if (print /* && t_last+dt < t */) { fprintf (file, "%.15f %.15f %.15f\n", t, y[0], y[1]/* , y[2], y[3] */); t_last+=dt; dt*=PRINT_DT_RATIO; } /* printf("%.15f\r",t); */ } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); if (print) { fprintf( file, "\n\n\n" ); fclose( file ); } return y[1]; }
static PyObject * PyGSL_odeiv_evolve_apply_array(PyGSL_odeiv_evolve *self, PyObject *args) { PyObject *result = NULL; PyObject *y0_o = NULL; PyObject *t_o = NULL; PyArrayObject *volatile y0 = NULL, *volatile yout = NULL, *volatile ta = NULL; double t=0, h=0, t1 = 0, flag; double *y0_data = NULL, *yout_data = NULL; int dimension, r, dims[2]; int nlen=-1, i, j; assert(PyGSL_ODEIV_EVOLVE_Check(self)); FUNC_MESS_BEGIN(); if(! PyArg_ParseTuple(args, "OdO", &t_o, &h, &y0_o)){ return NULL; } dimension = self->step->system.dimension; ta = PyGSL_PyArray_PREPARE_gsl_vector_view(t_o, PyArray_DOUBLE, 1, -1, 1, NULL); if(ta == NULL) goto fail; nlen = ta->dimensions[0]; y0 = PyGSL_PyArray_PREPARE_gsl_vector_view(y0_o, PyArray_DOUBLE, 1, dimension, 1, NULL); if(y0 == NULL) goto fail; dims[0] = nlen; dims[1] = dimension; yout = (PyArrayObject *) PyArray_FromDims(2, dims, PyArray_DOUBLE); if(yout == NULL) goto fail; if((flag=setjmp(self->step->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); goto fail; } DEBUG_MESS(5, "\t\t Yout Layout %p, shape=[%d,%d], strides=[%d,%d]", yout->data, yout->dimensions[0], yout->dimensions[1], yout->strides[0], yout->strides[1]); r = GSL_CONTINUE; yout_data = (double *)(yout->data); /* Copy the start vector */ for(j=0; j<dimension; j++){ yout_data[j] = *((double *)(y0->data + y0->strides[0] * j)); } for(i=1; i<nlen; i++){ y0_data = (double *)(yout->data + yout->strides[0]*(i-1)); yout_data = (double *)(yout->data + yout->strides[0]*(i) ); /* Copy the start vector */ for(j=0; j<dimension; j++){ yout_data[j] = y0_data[j]; } t = *((double *) (ta->data + ta->strides[0]*(i-1)) ); t1 = *((double *) (ta->data + ta->strides[0]*(i) ) ); while(t<t1){ r = gsl_odeiv_evolve_apply(self->evolve, self->control->control, self->step->step, &(self->step->system), &t, t1, &h, yout_data); /* All GSL Errors are > 0. */ if (r != GSL_SUCCESS){ goto fail; } } assert(r == GSL_SUCCESS); } result = (PyObject *) yout; /* Deleting the arrays */ Py_DECREF(y0); y0=NULL; Py_DECREF(ta); FUNC_MESS_END(); return result; fail: FUNC_MESS("IN Fail"); PyGSL_add_traceback(module, this_file, odeiv_step_init_err_msg, __LINE__); Py_XDECREF(ta); ta = NULL; Py_XDECREF(y0); y0=NULL; Py_XDECREF(yout); FUNC_MESS("IN Fail End"); return NULL; }
static PyObject * PyGSL_odeiv_evolve_apply(PyGSL_odeiv_evolve *self, PyObject *args) { PyObject *result = NULL; PyObject *y0_o = NULL; PyArrayObject *volatile y0 = NULL, *volatile yout = NULL; double t=0, h=0, t1 = 0, flag; int dimension, r; assert(PyGSL_ODEIV_EVOLVE_Check(self)); FUNC_MESS_BEGIN(); if(! PyArg_ParseTuple(args, "dddO", &t, &t1, &h, &y0_o)){ return NULL; } dimension = self->step->system.dimension; y0 = PyGSL_PyArray_PREPARE_gsl_vector_view(y0_o, PyArray_DOUBLE, 1, dimension, 1, NULL); if(y0 == NULL) goto fail; yout = (PyArrayObject *) PyArray_CopyFromObject((PyObject * ) y0, PyArray_DOUBLE, 1, 1); if(yout == NULL) goto fail; if((flag=setjmp(self->step->buffer)) == 0){ FUNC_MESS("\t\t Setting Jmp Buffer"); } else { FUNC_MESS("\t\t Returning from Jmp Buffer"); goto fail; } r = gsl_odeiv_evolve_apply(self->evolve, self->control->control, self->step->step, &(self->step->system), &t, t1, &h, (double * )yout->data); if (GSL_SUCCESS != r){ goto fail; } assert(yout != NULL); result = Py_BuildValue("(ddO)", t, h, yout); /* Deleting the arrays */ /* Do I need to do that??? Not transfered Py_DECREF(yout); yout = NULL; */ Py_DECREF(y0); y0=NULL; FUNC_MESS_END(); return result; fail: FUNC_MESS("IN Fail"); PyGSL_add_traceback(module, this_file, odeiv_step_init_err_msg, __LINE__); Py_XDECREF(y0); Py_XDECREF(yout); FUNC_MESS("IN Fail End"); return NULL; }
void nest::iaf_cond_alpha_mc::update( Time const& origin, const long from, const long to ) { assert( to >= 0 && ( delay ) from < kernel().connection_manager.get_min_delay() ); assert( from < to ); for ( long lag = from; lag < to; ++lag ) { double t = 0.0; // numerical integration with adaptive step size control: // ------------------------------------------------------ // gsl_odeiv_evolve_apply performs only a single numerical // integration step, starting from t and bounded by step; // the while-loop ensures integration over the whole simulation // step (0, step] if more than one integration step is needed due // to a small integration step size; // note that (t+IntegrationStep > step) leads to integration over // (t, step] and afterwards setting t to step, but it does not // enforce setting IntegrationStep to step-t; this is of advantage // for a consistent and efficient integration across subsequent // simulation intervals while ( t < B_.step_ ) { const int status = gsl_odeiv_evolve_apply( B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &t, // from t B_.step_, // to t <= step &B_.IntegrationStep_, // integration step size S_.y_ ); // neuronal state if ( status != GSL_SUCCESS ) { throw GSLSolverFailure( get_name(), status ); } } // add incoming spikes at end of interval // exploit here that spike buffers are compartment for compartment, // alternating between excitatory and inhibitory for ( size_t n = 0; n < NCOMP; ++n ) { S_.y_[ n * State_::STATE_VEC_COMPS + State_::DG_EXC ] += B_.spikes_[ 2 * n ].get_value( lag ) * V_.PSConInit_E_[ n ]; S_.y_[ n * State_::STATE_VEC_COMPS + State_::DG_INH ] += B_.spikes_[ 2 * n + 1 ].get_value( lag ) * V_.PSConInit_I_[ n ]; } // refractoriness and spiking // exploit here that plain offset enum value V_M indexes soma V_M if ( S_.r_ ) { // neuron is absolute refractory --S_.r_; S_.y_[ State_::V_M ] = P_.V_reset; } else if ( S_.y_[ State_::V_M ] >= P_.V_th ) { // neuron fires spike S_.r_ = V_.RefractoryCounts_; S_.y_[ State_::V_M ] = P_.V_reset; set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); SpikeEvent se; kernel().event_delivery_manager.send( *this, se, lag ); } // set new input currents for ( size_t n = 0; n < NCOMP; ++n ) { B_.I_stim_[ n ] = B_.currents_[ n ].get_value( lag ); } // log state data B_.logger_.record_data( origin.get_steps() + lag ); } }
void nest::iaf_cond_exp::update( Time const& origin, const long_t from, const long_t to ) { assert( to >= 0 && ( delay ) from < Scheduler::get_min_delay() ); assert( from < to ); for ( long_t lag = from; lag < to; ++lag ) { double t = 0.0; // numerical integration with adaptive step size control: // ------------------------------------------------------ // gsl_odeiv_evolve_apply performs only a single numerical // integration step, starting from t and bounded by step; // the while-loop ensures integration over the whole simulation // step (0, step] if more than one integration step is needed due // to a small integration step size; // note that (t+IntegrationStep > step) leads to integration over // (t, step] and afterwards setting t to step, but it does not // enforce setting IntegrationStep to step-t; this is of advantage // for a consistent and efficient integration across subsequent // simulation intervals while ( t < B_.step_ ) { const int status = gsl_odeiv_evolve_apply( B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &t, // from t B_.step_, // to t <= step &B_.IntegrationStep_, // integration step size S_.y_ ); // neuronal state if ( status != GSL_SUCCESS ) throw GSLSolverFailure( get_name(), status ); } S_.y_[ State_::G_EXC ] += B_.spike_exc_.get_value( lag ); S_.y_[ State_::G_INH ] += B_.spike_inh_.get_value( lag ); // absolute refractory period if ( S_.r_ ) { // neuron is absolute refractory --S_.r_; S_.y_[ State_::V_M ] = P_.V_reset_; } else // neuron is not absolute refractory if ( S_.y_[ State_::V_M ] >= P_.V_th_ ) { S_.r_ = V_.RefractoryCounts_; S_.y_[ State_::V_M ] = P_.V_reset_; set_spiketime( Time::step( origin.get_steps() + lag + 1 ) ); SpikeEvent se; network()->send( *this, se, lag ); } // set new input current B_.I_stim_ = B_.currents_.get_value( lag ); // log state data B_.logger_.record_data( origin.get_steps() + lag ); } }
/** * @brief Integrates the Tolman-Oppenheimer-Volkov stellar structure equations. * @details * Solves the Tolman-Oppenheimer-Volkov stellar structure equations using the * pseudo-enthalpy formalism introduced in: * Lindblom (1992) "Determining the Nuclear Equation of State from Neutron-Star * Masses and Radii", Astrophys. J. 398 569. * @param[out] radius The radius of the star in m. * @param[out] mass The mass of the star in kg. * @param[out] love_number_k2 The k_2 tidal love number of the star. * @param[in] central_pressure_si The central pressure of the star in Pa. * @param eos Pointer to the Equation of State structure. * @retval 0 Success. * @retval <0 Failure. */ int XLALSimNeutronStarTOVODEIntegrate(double *radius, double *mass, double *love_number_k2, double central_pressure_si, LALSimNeutronStarEOS * eos) { /* ode integration variables */ const double epsabs = 0.0, epsrel = 1e-6; double y[TOV_ODE_VARS_DIM]; double dy[TOV_ODE_VARS_DIM]; struct tov_ode_vars *vars = tov_ode_vars_cast(y); gsl_odeiv_system sys = { tov_ode, NULL, TOV_ODE_VARS_DIM, eos }; gsl_odeiv_step *step = gsl_odeiv_step_alloc(gsl_odeiv_step_rk8pd, TOV_ODE_VARS_DIM); gsl_odeiv_control *ctrl = gsl_odeiv_control_y_new(epsabs, epsrel); gsl_odeiv_evolve *evolv = gsl_odeiv_evolve_alloc(TOV_ODE_VARS_DIM); /* central values */ /* note: will be updated with Lindblom's series expansion */ /* geometrisized units for variables in length (m) */ double pc = central_pressure_si * LAL_G_C4_SI; double ec = XLALSimNeutronStarEOSEnergyDensityOfPressureGeometerized(pc, eos); double hc = XLALSimNeutronStarEOSPseudoEnthalpyOfPressureGeometerized(pc, eos); double dedp_c = XLALSimNeutronStarEOSEnergyDensityDerivOfPressureGeometerized(pc, eos); double dhdp_c = 1.0 / (ec + pc); double dedh_c = dedp_c / dhdp_c; double dh = -1e-3 * hc; double h0 = hc + dh; double h1 = 0.0 - dh; double r0 = sqrt(-3.0 * dh / (2.0 * LAL_PI * (ec + 3.0 * pc))); double m0 = 4.0 * LAL_PI * r0 * r0 * r0 * ec / 3.0; double H0 = r0 * r0; double b0 = 2.0 * r0; double yy; double c; double h; size_t i; /* series expansion for the initial core */ /* second factor of Eq. (7) of Lindblom (1992) */ r0 *= 1.0 + 0.25 * dh * (ec - 3.0 * pc - 0.6 * dedh_c) / (ec + 3.0 * pc); /* second factor of Eq. (8) of Lindblom (1992) */ m0 *= 1.0 + 0.6 * dh * dedh_c / ec; /* perform integration */ vars->r = r0; vars->m = m0; vars->H = H0; vars->b = b0; h = h0; while (h > h1) { int s = gsl_odeiv_evolve_apply(evolv, ctrl, step, &sys, &h, h1, &dh, y); if (s != GSL_SUCCESS) XLAL_ERROR(XLAL_EERR, "Error encountered in GSL's ODE integrator\n"); } /* take one final Euler step to get to surface */ tov_ode(h, y, dy, eos); for (i = 0; i < TOV_ODE_VARS_DIM; ++i) y[i] += dy[i] * (0.0 - h1); /* compute tidal Love number k2 */ c = vars->m / vars->r; /* compactness */ yy = vars->r * vars->b / vars->H; /* convert from geometric units to SI units */ *radius = vars->r; *mass = vars->m * LAL_MSUN_SI / LAL_MRSUN_SI; *love_number_k2 = tidal_Love_number_k2(c, yy); /* free ode memory */ gsl_odeiv_evolve_free(evolv); gsl_odeiv_control_free(ctrl); gsl_odeiv_step_free(step); return 0; }
// The actual (user defined) qoi routine void qoiRoutine(const QUESO::GslVector& paramValues, const QUESO::GslVector* paramDirection, const void* functionDataPtr, QUESO::GslVector& qoiValues, QUESO::DistArray<QUESO::GslVector*>* gradVectors, QUESO::DistArray<QUESO::GslMatrix*>* hessianMatrices, QUESO::DistArray<QUESO::GslVector*>* hessianEffects) { if (paramDirection && functionDataPtr && gradVectors && hessianMatrices && hessianEffects) { // Just to eliminate INTEL compiler warnings } double A = paramValues[0]; double E = paramValues[1]; double beta = ((qoiRoutine_Data *) functionDataPtr)->m_beta; double criticalMass = ((qoiRoutine_Data *) functionDataPtr)->m_criticalMass; double criticalTime = ((qoiRoutine_Data *) functionDataPtr)->m_criticalTime; double params[]={A,E,beta}; // integration const gsl_odeiv_step_type *T = gsl_odeiv_step_rkf45; //rkf45; //gear1; gsl_odeiv_step *s = gsl_odeiv_step_alloc(T,1); gsl_odeiv_control *c = gsl_odeiv_control_y_new(1e-6,0.0); gsl_odeiv_evolve *e = gsl_odeiv_evolve_alloc(1); gsl_odeiv_system sys = {func, NULL, 1, (void *)params}; double temperature = 0.1; double h = 1e-3; double Mass[1]; Mass[0]=1.; double temperature_old = 0.; double M_old[1]; M_old[0]=1.; double crossingTemperature = 0.; //unsigned int loopSize = 0; while ((temperature < criticalTime*beta) && (Mass[0] > criticalMass )) { int status = gsl_odeiv_evolve_apply(e, c, s, &sys, &temperature, criticalTime*beta, &h, Mass); UQ_FATAL_TEST_MACRO((status != GSL_SUCCESS), paramValues.env().fullRank(), "qoiRoutine()", "gsl_odeiv_evolve_apply() failed"); //printf("t = %6.1lf, mass = %10.4lf\n",t,Mass[0]); //loopSize++; if (Mass[0] <= criticalMass) { crossingTemperature = temperature_old + (temperature - temperature_old) * (M_old[0]-criticalMass)/(M_old[0]-Mass[0]); } temperature_old=temperature; M_old[0]=Mass[0]; } if (criticalMass > 0.) qoiValues[0] = crossingTemperature/beta; // QoI = time to achieve critical mass if (criticalTime > 0.) qoiValues[0] = Mass[0]; // QoI = mass fraction remaining at critical time //printf("loopSize = %d\n",loopSize); if ((paramValues.env().displayVerbosity() >= 3) && (paramValues.env().fullRank() == 0)) { printf("In qoiRoutine(), A = %g, E = %g, beta = %.3lf, criticalTime = %.3lf, criticalMass = %.3lf: qoi = %lf.\n",A,E,beta,criticalTime,criticalMass,qoiValues[0]); } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free(c); gsl_odeiv_step_free (s); return; }
double fevol_shrinker_eigenproblem (double bisec_param, int print, char * filename, void * p) { const gsl_odeiv_step_type * T = STEPPER; gsl_odeiv_step * s = gsl_odeiv_step_alloc (T, 4); gsl_odeiv_control * c = gsl_odeiv_control_y_new (STEPPER_ERROR, 0.0); gsl_odeiv_evolve * e = gsl_odeiv_evolve_alloc (4); double dt=PRINT_DT, t_last=0.; gsl_odeiv_system sys = {func_shrinker_eigenproblem, jac_dummy, 4, (void*)&bisec_param}; double t = T0; double h = H0; double A = *(double*)p; double y[4] = { /* expressions derived using ~/SeriesSolve.nb */ A*t + ((3*A - 4*(-1 + k)*pow(A,3))*pow(2 + k,-1)*pow(t,3))/12. + (A*(15 - 40*(-1 + k)*pow(A,2) + 16*pow(A,4)*(1 - 3*k + 2*pow(k,2)))* pow(t,5)*pow(8 + 6*k + pow(k,2),-1))/160., A + ((3*A - 4*(-1 + k)*pow(A,3))*pow(2 + k,-1)*pow(t,2))/4. + (A*(15 - 40*(-1 + k)*pow(A,2) + 16*pow(A,4)*(1 - 3*k + 2*pow(k,2)))* pow(t,4)*pow(8 + 6*k + pow(k,2),-1))/32., t, 1. }; FILE * file; if (print){ file = fopen(filename, "a"); fprintf(file, "# A = %.15f\n# lambda = %.15f\n", A, bisec_param ); } while (t < T_MAX) { int status = gsl_odeiv_evolve_apply (e, c, s, &sys, &t, T_MAX, &h, y); if (status != GSL_SUCCESS) break; /* are we still in the strip [0,pi]? is the lienarized solution reasonably boundaed?*/ if ( 0. > y[0] || y[0] > 3.15 || fabs(y[2]) > 10. ) break; if (print /* && t_last+dt < t */) { fprintf (file, "%.15E %.15E %.15E %.15E %.15E\n", t, y[0], y[1], y[2], y[3]); t_last+=dt; dt*=PRINT_DT_RATIO; } /* printf("%.15f\r",t); */ } gsl_odeiv_evolve_free (e); gsl_odeiv_control_free (c); gsl_odeiv_step_free (s); if (print) { fprintf( file, "\n\n\n" ); fclose( file ); } return y[2]; }
void nest::aeif_cond_exp::update(const Time &origin, const long_t from, const long_t to) { assert ( to >= 0 && (delay) from < Scheduler::get_min_delay() ); assert ( from < to ); assert ( State_::V_M == 0 ); for ( long_t lag = from; lag < to; ++lag ) { double t = 0.0; if ( S_.r_ > 0 ) --S_.r_; // numerical integration with adaptive step size control: // ------------------------------------------------------ // gsl_odeiv_evolve_apply performs only a single numerical // integration step, starting from t and bounded by step; // the while-loop ensures integration over the whole simulation // step (0, step] if more than one integration step is needed due // to a small integration step size; // note that (t+IntegrationStep > step) leads to integration over // (t, step] and afterwards setting t to step, but it does not // enforce setting IntegrationStep to step-t while ( t < B_.step_ ) { const int status = gsl_odeiv_evolve_apply(B_.e_, B_.c_, B_.s_, &B_.sys_, // system of ODE &t, // from t B_.step_, // to t <= step &B_.IntegrationStep_, // integration step size S_.y_); // neuronal state if ( status != GSL_SUCCESS ) throw GSLSolverFailure(get_name(), status); // check for unreasonable values; we allow V_M to explode if ( S_.y_[State_::V_M] < -1e3 || S_.y_[State_::W ] < -1e6 || S_.y_[State_::W] > 1e6 ) throw NumericalInstability(get_name()); // spikes are handled inside the while-loop // due to spike-driven adaptation if ( S_.r_ > 0 ) S_.y_[State_::V_M] = P_.V_reset_; else if ( S_.y_[State_::V_M] >= P_.V_peak_ ) { S_.y_[State_::V_M] = P_.V_reset_; S_.y_[State_::W] += P_.b; // spike-driven adaptation S_.r_ = V_.RefractoryCounts_; set_spiketime(Time::step(origin.get_steps() + lag + 1)); SpikeEvent se; network()->send(*this, se, lag); } } S_.y_[State_::G_EXC] += B_.spike_exc_.get_value(lag); S_.y_[State_::G_INH] += B_.spike_inh_.get_value(lag); // set new input current B_.I_stim_ = B_.currents_.get_value(lag); // log state data B_.logger_.record_data(origin.get_steps() + lag); } }