Ejemplo n.º 1
0
PropagationCK::Y PropagationCK::dYdt(const Y &y, ParticleState &p, double z) const {
	// normalize direction vector to prevent numerical losses
	Vector3d velocity = y.u.getUnitVector() * c_light;
	Vector3d B(0, 0, 0);
	try {
		B = field->getField(y.x, z);
	} catch (std::exception &e) {
		std::cerr << "PropagationCK: Exception in getField." << std::endl;
		std::cerr << e.what() << std::endl;
	}
	// Lorentz force: du/dt = q*c/E * (v x B)
	Vector3d dudt = p.getCharge() * c_light / p.getEnergy() * velocity.cross(B);
	return Y(velocity, dudt);
}