60 likes | 135 Views
Updating a Langevin Simulation. Update. bool stop = false; while(!stop) { NormalizeSpins(spins); if(simulation_time<=0) // t<0 is for relaxation of initial condition RelaxMeasure(simulation_time,spins,model); if(simulation_time>=0)
E N D
Update bool stop = false; while(!stop) { NormalizeSpins(spins); if(simulation_time<=0) // t<0 is for relaxation of initial condition RelaxMeasure(simulation_time,spins,model); if(simulation_time>=0) Measure(simulation_time,spins,model); // static GlobalMag GlobalMag("dummy",false); // no output Vec3 global_mag = GlobalMag(simulation_time,spins,model); if( global_mag[2]<stop_mag ) stop = true; // if( !stop ) { Real next_time = simulation_time + dt_meas; integration(llg_operator,rng,simulation_time,next_time,spins); simulation_time = next_time; } } // while !stop
Integration LLG: Rotation: Impulse:
Epsilon Fluctuation-dissipation relation
LLG evaluation // evaluates the LLG equation from one set of quantities s,h,dydt. template<class SpinModel> void LLGOperator<SpinModel>::LLGRHS(const orient_type &spin, const field_type &field, field_type &dydt) { // this implementation assumes that dependent_variable and field_container // are random access containers with value_type that is of type // Vec<Real,3> or can be implicitly converted into Vec<Real,3> const Real *s = static_cast<const Real*>(&(spin[0])); const Real *h = static_cast<const Real*>(&(field[0])); // This is S x H Real kx = h[2] * s[1] - h[1] * s[2]; Real ky = h[0] * s[2] - h[2] * s[0]; Real kz = h[1] * s[0] - h[0] * s[1]; // The triple product S x ( S x H ) is expanded to S.H S - H Real sh = s[0] * h[0] + s[1] * h[1] + s[2] * h[2]; // This includes the triple product in the vector k kx += damping * (sh * s[0] - h[0]); ky += damping * (sh * s[1] - h[1]); kz += damping * (sh * s[2] - h[2]); // finish off factor*M[ SxH - damping Sx(SxH) ] dydt[0] = factor * kx; dydt[1] = factor * ky; dydt[2] = factor * kz; }
Update bool stop = false; while(!stop) { NormalizeSpins(spins); if(simulation_time<=0) // t<0 is for relaxation of initial condition RelaxMeasure(simulation_time,spins,model); if(simulation_time>=0) Measure(simulation_time,spins,model); // static GlobalMag GlobalMag("dummy",false); // no output Vec3 global_mag = GlobalMag(simulation_time,spins,model); if( global_mag[2]<stop_mag ) stop = true; // if( !stop ) { Real next_time = simulation_time + dt_meas; integration(llg_operator,rng,simulation_time,next_time,spins); simulation_time = next_time; } } // while !stop