diff --git a/.gitignore b/.gitignore index 99be97d9..a9fd4aa9 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ *.blend *.blend1 .idea/ +*/.ds_store diff --git a/examples/dipole_trap.rs b/examples/dipole_trap.rs index 2d615906..57e71d29 100644 --- a/examples/dipole_trap.rs +++ b/examples/dipole_trap.rs @@ -14,7 +14,7 @@ use nalgebra::Vector3; use specs::prelude::*; use std::time::Instant; -const BEAM_NUMBER: usize = 2; +const BEAM_NUMBER: usize = 1; fn main() { let now = Instant::now(); @@ -23,39 +23,21 @@ fn main() { let mut sim_builder = SimulationBuilder::default(); sim_builder.add_plugin(LaserPlugin::<{BEAM_NUMBER}>); sim_builder.add_plugin(DipolePlugin::<{BEAM_NUMBER}>); - sim_builder.add_plugin(FileOutputPlugin::::new("pos.txt".to_string(), 100)); - sim_builder.add_plugin(FileOutputPlugin::::new("vel.txt".to_string(), 100)); - sim_builder.add_plugin(FileOutputPlugin::::new("position.xyz".to_string(), 100)); + sim_builder.add_plugin(FileOutputPlugin::::new("pos.txt".to_string(), 1)); + sim_builder.add_plugin(FileOutputPlugin::::new("vel.txt".to_string(), 1)); + sim_builder.add_plugin(FileOutputPlugin::::new("position.xyz".to_string(), 1)); let mut sim = sim_builder.build(); // Create dipole laser. - let power = 10.0; - let e_radius = 60.0e-6 / (2.0_f64.sqrt()); + let power = 100.0; + let e_radius = 60.0e-6 / 2.0_f64.sqrt(); let wavelength = 1064.0e-9; let gaussian_beam = GaussianBeam { intersection: Vector3::new(0.0, 0.0, 0.0), e_radius, power, - direction: Vector3::x(), - rayleigh_range: crate::laser::gaussian::calculate_rayleigh_range(&wavelength, &e_radius), - ellipticity: 0.0, - }; - sim.world - .create_entity() - .with(gaussian_beam) - .with(dipole::DipoleLight { wavelength }) - .with(laser::frame::Frame { - x_vector: Vector3::y(), - y_vector: Vector3::z(), - }) - .build(); - - let gaussian_beam = GaussianBeam { - intersection: Vector3::new(0.0, 0.0, 0.0), - e_radius, - power, - direction: Vector3::y(), + direction: Vector3::z(), rayleigh_range: crate::laser::gaussian::calculate_rayleigh_range(&wavelength, &e_radius), ellipticity: 0.0, }; @@ -65,20 +47,17 @@ fn main() { .with(dipole::DipoleLight { wavelength }) .with(laser::frame::Frame { x_vector: Vector3::x(), - y_vector: Vector3::z(), + y_vector: Vector3::y(), }) .build(); - // Define timestep - sim.world.insert(Timestep { delta: 1.0e-5 }); - // Create a single test atom sim.world .create_entity() .with(atom::Mass { value: 87.0 }) .with(atom::Force::new()) .with(atom::Position { - pos: Vector3::new(-5.0e-6, 5.0e-6, 5.0e-6), + pos: Vector3::new(1.0e-7, 1.0e-7, 1.0e-7), }) .with(atom::Velocity { vel: Vector3::new(0.0, 0.0, 0.0), @@ -90,8 +69,11 @@ fn main() { .with(lib::initiate::NewlyCreated) .build(); + // Define timestep + sim.world.insert(Timestep { delta: 1.0e-7 }); + // Run the simulation for a number of steps. - for _i in 0..100_000 { + for _i in 0..200_000 { sim.step(); } diff --git a/examples/top_trap_with_collisions.rs b/examples/top_trap_with_collisions.rs index 5e5174a8..395d0d33 100644 --- a/examples/top_trap_with_collisions.rs +++ b/examples/top_trap_with_collisions.rs @@ -7,7 +7,8 @@ use lib::collisions::CollisionPlugin; use lib::collisions::{ApplyCollisionsOption, CollisionParameters, CollisionsTracker}; use lib::initiate::NewlyCreated; use lib::integrator::Timestep; -use lib::magnetic::force::{ApplyMagneticForceSystem, MagneticDipole}; +// use lib::magnetic::force::{ApplyMagneticForceSystem, MagneticDipole}; +use lib::magnetic::force::{MagneticDipole}; use lib::magnetic::quadrupole::QuadrupoleField3D; use lib::magnetic::top::TimeOrbitingPotential; use lib::magnetic::MagneticTrapPlugin; diff --git a/src/constant.rs b/src/constant.rs index 4ce4d969..4f36537f 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -9,10 +9,10 @@ pub const GC: f64 = 9.80665; /// Mathematical constant exp(1) pub const EXP: f64 = std::f64::consts::E; -/// Mathematica constant pi +/// Mathematical constant pi pub const PI: f64 = std::f64::consts::PI; -// The Bohr magneton, defined in SI units of Joules/Tesla. +/// The Bohr magneton, defined in SI units of Joules/Tesla. pub const BOHRMAG: f64 = 9.274e-24; /// Boltzmann constant in SI units @@ -22,7 +22,10 @@ pub const BOLTZCONST: f64 = 1.38e-23; pub const AMU: f64 = 1.6605e-27; /// Speed of light in SI units of m/s -pub const C: f64 = 299297458.0; +pub const C: f64 = 299792458.0; /// Sqrt of 2 pub const SQRT2: f64 = std::f64::consts::SQRT_2; + +/// Vacuum permittivity [F/m] +pub const EPSILON0: f64 = 8.8541878128e-12; diff --git a/src/dipole/force.rs b/src/dipole/force.rs index 233c0ca2..7d1d422b 100644 --- a/src/dipole/force.rs +++ b/src/dipole/force.rs @@ -6,6 +6,7 @@ use crate::atom::Force; use crate::dipole::DipoleLight; use crate::dipole::Polarizability; use crate::laser::index::LaserIndex; +use crate::constant; /// Calculates forces exerted onto the atoms by dipole laser beams. /// @@ -28,10 +29,10 @@ impl<'a, const N: usize> System<'a> for ApplyDipoleForceSystem { ) { (&mut force, &polarizability, &gradient_sampler) .par_join() - .for_each(|(force, polarizability, sampler)| { + .for_each( |(force, polarizability, sampler)| { for (index, _dipole) in (&dipole_index, &dipole_light).join() { - force.force += - polarizability.prefactor * sampler.contents[index.index].gradient; + force.force += polarizability.prefactor*sampler.contents[index.index].gradient/ + ( 2.0 * constant::EPSILON0 * constant::C ); } }); } @@ -50,6 +51,9 @@ pub mod tests { use crate::laser::gaussian::GaussianBeam; use crate::laser::DEFAULT_BEAM_LIMIT; use nalgebra::Vector3; + // use crate::atom::Position; + // use crate::laser::frame::Frame; + // use crate::laser::intensity_gradient::LaserIntensityGradientSampler; #[test] fn test_apply_dipole_force_system() { @@ -110,46 +114,46 @@ pub mod tests { fn test_apply_dipole_force_again_system() { let mut test_world = World::new(); - test_world.register::(); - test_world.register::(); - test_world.register::(); - test_world.register::>(); - test_world.register::(); + test_world.register::(); + test_world.register::(); + test_world.register::(); + test_world.register::>(); + test_world.register::(); - test_world - .create_entity() - .with(LaserIndex { - index: 0, - initiated: true, - }) - .with(DipoleLight { - wavelength: 1064.0e-9, - }) - .build(); + test_world + .create_entity() + .with(LaserIndex { + index: 0, + initiated: true, + }) + .with(DipoleLight { + wavelength: 1064.0e-9, + }) + .build(); - let transition = Polarizability::calculate_for(1064e-9, 461e-9, 32e6); - let atom1 = test_world - .create_entity() - .with(Force { - force: Vector3::new(0.0, 0.0, 0.0), - }) - .with(LaserIntensityGradientSamplers { - contents: [crate::laser::intensity_gradient::LaserIntensityGradientSampler { - gradient: Vector3::new(-8.4628e+7, -4.33992902e+13, -4.33992902e+13), - }; crate::laser::DEFAULT_BEAM_LIMIT], - }) - .with(transition) - .build(); - let mut system = ApplyDipoleForceSystem::<{ DEFAULT_BEAM_LIMIT }>; - system.run_now(&test_world); - test_world.maintain(); - let sampler_storage = test_world.read_storage::(); - let sim_result_force = sampler_storage.get(atom1).expect("Entity not found!").force; + let transition = Polarizability::calculate_for(1064e-9, 461e-9, 32e6); + let atom1 = test_world + .create_entity() + .with(Force { + force: Vector3::new(0.0, 0.0, 0.0), + }) + .with(LaserIntensityGradientSamplers { + contents: [crate::laser::intensity_gradient::LaserIntensityGradientSampler { + gradient: Vector3::new(-8.4628e+7, -4.33992902e+13, -4.33992902e+13), + }; crate::laser::DEFAULT_BEAM_LIMIT], + }) + .with(transition) + .build(); + let mut system = ApplyDipoleForceSystem::<{ DEFAULT_BEAM_LIMIT }>; + system.run_now(&test_world); + test_world.maintain(); + let sampler_storage = test_world.read_storage::(); + let sim_result_force = sampler_storage.get(atom1).expect("Entity not found!").force; - assert_approx_eq!(-6.386888332902177e-29, sim_result_force[0], 3e-30_f64); - assert_approx_eq!(-3.11151847e-23, sim_result_force[1], 2e-24_f64); - assert_approx_eq!(-3.11151847e-23, sim_result_force[2], 2e-24_f64); - } + assert_approx_eq!(-1.579e-26, sim_result_force[0], 3e-30_f64); + assert_approx_eq!(-8.097e-21, sim_result_force[1], 2e-24_f64); + assert_approx_eq!(-8.097e-21, sim_result_force[2], 2e-24_f64); + } #[test] fn test_apply_dipole_force_and_gradient_system() { @@ -175,6 +179,7 @@ pub mod tests { rayleigh_range: crate::laser::gaussian::calculate_rayleigh_range(&1064.0e-9, &e_radius), ellipticity: 0.0, }; + test_world .create_entity() .with(gaussian_beam) @@ -190,6 +195,7 @@ pub mod tests { y_vector: Vector3::z(), }) .build(); + let gaussian_beam = GaussianBeam { intersection: Vector3::new(0.0, 0.0, 0.0), e_radius, @@ -198,6 +204,7 @@ pub mod tests { rayleigh_range: crate::laser::gaussian::calculate_rayleigh_range(&1064.0e-9, &e_radius), ellipticity: 0.0, }; + test_world .create_entity() .with(gaussian_beam) @@ -215,6 +222,7 @@ pub mod tests { .build(); let transition = Polarizability::calculate_for(1064e-9, 460.7e-9, 32e6); + let atom1 = test_world .create_entity() .with(crate::atom::Position { @@ -245,24 +253,21 @@ pub mod tests { .get(atom1) .expect("Entity not found!") .contents; - //println!("force is: {}", sim_result_force); - //println!("gradient 1 is: {}", sim_result_grad[0].gradient); - //println!("gradient 2 is: {}", sim_result_grad[1].gradient); assert_approx_eq!( - 0.000000000000000000000000000000000127913190642808, + 3.17e-32, sim_result_force[0], - 3e-46_f64 + 5e-33_f64 ); assert_approx_eq!( - 0.000000000000000000000000000000000127913190642808, + 3.17e-32, sim_result_force[1], - 2e-46_f64 + 5e-33_f64 ); assert_approx_eq!( - 0.000000000000000000000000000000000511875188257342, + 1.28e-31, sim_result_force[2], - 2e-46_f64 + 5e-33_f64 ); } } diff --git a/src/dipole/mod.rs b/src/dipole/mod.rs index 8c0d4b42..ed45da8d 100644 --- a/src/dipole/mod.rs +++ b/src/dipole/mod.rs @@ -46,7 +46,7 @@ impl Component for Polarizability { type Storage = VecStorage; } impl Polarizability { - /// Calculate the polarizability of an atom in a dipole beam of given wavelength, detuned from a strong optical transition. + /// Calculate the real part of the polarizability of an atom in a dipole beam of given wavelength, detuned from a strong optical transition. /// /// The wavelengths of both transitions are in SI units of m. /// The linewidth of the optical transition is in SI units of Hz. @@ -57,10 +57,11 @@ impl Polarizability { ) -> Polarizability { let transition_f = constant::C / optical_transition_wavelength; let dipole_f = constant::C / dipole_beam_wavelength; - let prefactor = -3. * constant::PI * constant::C.powf(2.0) - / (2. * (2. * constant::PI * transition_f).powf(3.0)) - * optical_transition_linewidth - * -(1. / (transition_f - dipole_f) + 1. / (transition_f + dipole_f)); + let prefactor = ( 3.0 * constant::PI * constant::C.powf(3.0) * constant::EPSILON0 / + transition_f.powf(3.0) ) * ( + optical_transition_linewidth / (transition_f - dipole_f) + + optical_transition_linewidth / (transition_f + dipole_f) + ); Polarizability { prefactor } } } @@ -83,11 +84,11 @@ impl<'a> System<'a> for AttachIndexToDipoleLightSystem { } /// This plugin implements a dipole force that can be used to confine cold atoms. -/// +/// /// See also [crate::dipole] -/// +/// /// # Generic Arguments -/// +/// /// * `N`: The maximum number of laser beams (must match the `LaserPlugin`). pub struct DipolePlugin; impl Plugin for DipolePlugin { diff --git a/src/laser/gaussian.rs b/src/laser/gaussian.rs index b3c94cc3..b08a4b0f 100644 --- a/src/laser/gaussian.rs +++ b/src/laser/gaussian.rs @@ -68,8 +68,9 @@ impl GaussianBeam { peak_intensity: f64, e_radius: f64, ) -> Self { - let std = e_radius / 2.0_f64.powf(0.5); - let power = 2.0 * std::f64::consts::PI * std.powi(2) * peak_intensity; + + let power = std::f64::consts::PI * e_radius.powi(2) * peak_intensity; + GaussianBeam { intersection, direction, @@ -102,8 +103,9 @@ impl GaussianBeam { e_radius: f64, wavelength: f64, ) -> Self { - let std = e_radius / 2.0_f64.powf(0.5); - let power = 2.0 * std::f64::consts::PI * std.powi(2) * peak_intensity; + + let power = std::f64::consts::PI * e_radius.powi(2) * peak_intensity; + GaussianBeam { intersection, direction, @@ -166,23 +168,25 @@ pub fn get_gaussian_beam_intensity( mask: Option<&CircularMask>, frame: Option<&Frame>, ) -> f64 { + let (z, distance_squared) = match frame { + // checking if frame is given (for calculating ellipticity) Some(frame) => { + let (x, y, z) = maths::get_relative_coordinates_line_point( &pos.pos, &beam.intersection, &beam.direction, frame, ); + let semi_major_axis = 1.0 / (1.0 - beam.ellipticity.powf(2.0)).powf(0.5); // the factor (1.0 / semi_major_axis) is necessary so the overall power of the beam is not changed. - ( - z, - (1.0 / semi_major_axis) * ((x).powf(2.0) + (y * semi_major_axis).powf(2.0)), - ) + ( z, (1.0 / semi_major_axis) * ((x).powf(2.0) + (y * semi_major_axis).powf(2.0)), ) } + // ellipticity will be ignored (i.e. treated as zero) if no `Frame` is supplied. None => { let (distance, z) = maths::get_minimum_distance_line_point( @@ -193,6 +197,7 @@ pub fn get_gaussian_beam_intensity( (z, distance * distance) } }; + let power = match mask { Some(mask) => { if distance_squared.powf(0.5) < mask.radius { @@ -203,12 +208,13 @@ pub fn get_gaussian_beam_intensity( } None => beam.power, }; - power / PI / beam.e_radius.powf(2.0) / (1.0 + (z / beam.rayleigh_range).powf(2.0)) - * EXP.powf( - -distance_squared - / (beam.e_radius.powf(2.0) * (1. + (z / beam.rayleigh_range).powf(2.0))), - ) + + let spot_size_squared = + 2.0 * beam.e_radius.powf(2.0) * (1. + (z / beam.rayleigh_range).powf(2.0)); + + 2.0 * power / ( PI * spot_size_squared ) * EXP.powf(-2.0 * distance_squared / spot_size_squared) } + /// Computes the rayleigh range for a given beam and wavelength pub fn calculate_rayleigh_range(wavelength: &f64, e_radius: &f64) -> f64 { 2.0 * PI * e_radius.powf(2.0) / wavelength @@ -221,24 +227,32 @@ pub fn get_gaussian_beam_intensity_gradient( pos: &Position, reference_frame: &Frame, ) -> Vector3 { + + let rela_coord = pos.pos - beam.intersection; // ellipticity treatment let semi_major_axis = 1.0 / (1.0 - beam.ellipticity.powf(2.0)).powf(0.5); - let x = rela_coord.dot(&reference_frame.x_vector) / semi_major_axis.powf(0.5); let y = rela_coord.dot(&reference_frame.y_vector) * semi_major_axis.powf(0.5); let z = rela_coord.dot(&beam.direction); + //Calculate the spot_size_squared for convenience of later calculations. let spot_size_squared = - 2.0 * beam.e_radius.powf(2.0) * (1. + (z / beam.rayleigh_range).powf(2.0)); - let vector = -4. * (reference_frame.x_vector * x + reference_frame.y_vector * y) - + beam.direction * z / (beam.rayleigh_range.powf(2.0) + z.powf(2.0)) - * (-spot_size_squared + 4. * (x.powf(2.0) + y.powf(2.0))); - let intensity = 2. * beam.power / PI / spot_size_squared - * EXP.powf(-2. * (x.powf(2.0) + y.powf(2.0)) / spot_size_squared); - - intensity / spot_size_squared * vector + 2.0 * beam.e_radius.powf(2.0) * (1. + (z / beam.rayleigh_range).powf(2.0)); + + //Calculating the gradient vector for grad(I(r,z)). + let vector = - 4.0 * ( reference_frame.x_vector * x + reference_frame.y_vector * y ) + + 2.0 * beam.direction * ( z / ( beam.rayleigh_range.powf(2.0) + z.powf(2.0) ) ) + * ( 2.0 * (x.powf(2.0) + y.powf(2.0)) - spot_size_squared); + + //Calculate the intensity at pos (x, y, z). + let intensity = 2.0 * beam.power / ( PI * spot_size_squared ) + * EXP.powf(-2.0 * (x.powf(2.0) + y.powf(2.0)) / spot_size_squared); + + //Returns the full grad(I) with correct magnitude and direction. + vector * intensity / spot_size_squared + } #[cfg(test)] @@ -258,13 +272,13 @@ pub mod tests { let beam = GaussianBeam { direction: Vector3::z(), intersection: Vector3::new(0.0, 0.0, 0.0), - e_radius: 70.71067812e-6, - power: 100.0, - rayleigh_range: calculate_rayleigh_range(&1064.0e-9, &70.71067812e-6), + e_radius: 60e-6, + power: 10.0, + rayleigh_range: calculate_rayleigh_range(&1064.0e-9, &60e-6), ellipticity: 0.0, }; let pos1 = Position { - pos: Vector3::new(10.0e-6, 0.0, 30.0e-6), + pos: Vector3::new(1.0e-7, 1.2e-6, 6.0e-7), }; let grf = Frame { x_vector: Vector3::x(), @@ -272,9 +286,10 @@ pub mod tests { }; let gradient = get_gaussian_beam_intensity_gradient(&beam, &pos1, &grf); - assert_approx_eq!(gradient[0], -2.49605032e+13, 1e+8_f64); - assert_approx_eq!(gradient[1], 0.0, 1e+9_f64); - assert_approx_eq!(gradient[2], -2.06143366e+08, 1e+6_f64); + + assert_approx_eq!(gradient[0], -4.91021e+10, 1e+9_f64); + assert_approx_eq!(gradient[1], -5.89225e+11, 1e+9_f64); + assert_approx_eq!(gradient[2], -9.38334e+6, 1e+9_f64); } #[test] diff --git a/src/laser/intensity.rs b/src/laser/intensity.rs index e3d8b590..6512e74a 100644 --- a/src/laser/intensity.rs +++ b/src/laser/intensity.rs @@ -12,6 +12,7 @@ use crate::atom::Position; use crate::laser::index::LaserIndex; use serde::Serialize; use specs::prelude::*; +use std::fmt; const LASER_CACHE_SIZE: usize = 16; @@ -31,6 +32,14 @@ impl Default for LaserIntensitySampler { } } +impl Component for LaserIntensitySampler { + type Storage = VecStorage; +} +impl fmt::Display for LaserIntensitySampler { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self.intensity) +}} + /// Component that holds a list of `LaserIntensitySamplers` #[derive(Copy, Clone, Serialize)] pub struct LaserIntensitySamplers { @@ -43,6 +52,12 @@ impl Component for LaserIntensitySamplers { type Storage = VecStorage; } +impl fmt::Display for LaserIntensitySamplers { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "({}, {}, 0.0)", self.contents[0], self.contents[1]) + } +} + /// This system initialises all `LaserIntensitySamplers` to a NAN value. /// /// It also ensures that the size of the `LaserIntensitySamplers` components match the number of CoolingLight entities in the world. @@ -153,39 +168,45 @@ pub mod tests { test_world.register::(); test_world.register::>(); + let beam = GaussianBeam { + direction: Vector3::x(), + intersection: Vector3::new(0.0, 0.0, 0.0), + e_radius: 2.0, + power: 1.0, + rayleigh_range: gaussian::calculate_rayleigh_range(&461.0e-9, &2.0), + ellipticity: 0.0, + }; + test_world .create_entity() .with(LaserIndex { index: 0, initiated: true, }) - .with(GaussianBeam { - direction: Vector3::new(1.0, 0.0, 0.0), - intersection: Vector3::new(0.0, 0.0, 0.0), - e_radius: 2.0, - power: 1.0, - rayleigh_range: gaussian::calculate_rayleigh_range(&461.0e-9, &2.0), - ellipticity: 0.0, - }) + .with(beam) .build(); let atom1 = test_world .create_entity() - .with(Position { pos: Vector3::y() }) + .with(Position { pos: Vector3::new( 0.0, 1.0, 0.0 ) }) .with(LaserIntensitySamplers { contents: [LaserIntensitySampler::default(); crate::laser::DEFAULT_BEAM_LIMIT], }) .build(); let mut system = SampleLaserIntensitySystem::<{ DEFAULT_BEAM_LIMIT }>; + system.run_now(&test_world); + test_world.maintain(); - let sampler_storage = - test_world.read_storage::>(); + + let sampler_storage = test_world.read_storage::>(); let actual_intensity = gaussian::get_gaussian_beam_intensity( &GaussianBeam { - direction: Vector3::new(1.0, 0.0, 0.0), + direction: Vector3::x(), intersection: Vector3::new(0.0, 0.0, 0.0), e_radius: 2.0, power: 1.0, @@ -197,6 +218,7 @@ pub mod tests { None, ); + assert_approx_eq!( sampler_storage .get(atom1) diff --git a/src/laser/intensity_gradient.rs b/src/laser/intensity_gradient.rs index 395206b7..9d5a0a56 100644 --- a/src/laser/intensity_gradient.rs +++ b/src/laser/intensity_gradient.rs @@ -64,11 +64,11 @@ impl<'a, const N: usize> System<'a> for SampleGaussianLaserIntensityGradientSyst use rayon::prelude::*; for (_dipole, index, beam, reference) in - (&dipole, &index, &gaussian, &reference_frame).join() - { + (&dipole, &index, &gaussian, &reference_frame).join() { (&pos, &mut sampler).par_join().for_each(|(pos, sampler)| { - sampler.contents[index.index].gradient = - get_gaussian_beam_intensity_gradient(beam, pos, reference); + sampler.contents[index.index].gradient = get_gaussian_beam_intensity_gradient( + beam, pos, reference + ); }); } } @@ -173,6 +173,7 @@ pub mod tests { 1e+5_f64 ); } + #[test] fn test_sample_laser_intensity_gradient_again_system() { let mut test_world = World::new(); @@ -184,14 +185,16 @@ pub mod tests { test_world.register::(); test_world.register::(); + let e_rad = 70.71067812e-6; + let beam = GaussianBeam { direction: Vector3::x(), intersection: Vector3::new(0.0, 0.0, 0.0), - e_radius: 70.71067812e-6, + e_radius: e_rad, power: 100.0, rayleigh_range: crate::laser::gaussian::calculate_rayleigh_range( &1064.0e-9, - &70.71067812e-6, + &e_rad, ), ellipticity: 0.0, }; @@ -204,8 +207,8 @@ pub mod tests { }) .with(beam) .with(Frame { - x_vector: Vector3::y(), - y_vector: Vector3::z(), + x_vector: Vector3::z(), + y_vector: Vector3::y(), }) .with(DipoleLight { wavelength: 1064.0e-9, @@ -222,6 +225,7 @@ pub mod tests { crate::laser::DEFAULT_BEAM_LIMIT], }) .build(); + let mut system = SampleGaussianLaserIntensityGradientSystem::<{ DEFAULT_BEAM_LIMIT }>; system.run_now(&test_world); test_world.maintain(); @@ -233,8 +237,8 @@ pub mod tests { .contents[0] .gradient; - assert_approx_eq!(-8.4628e+7, sim_result_gradient[0], 1e+5_f64); - assert_approx_eq!(-4.33992902e+13, sim_result_gradient[1], 1e+8_f64); - assert_approx_eq!(-4.33992902e+13, sim_result_gradient[2], 1e+8_f64); + assert_approx_eq!( -2.09081e+8, sim_result_gradient[0], 1e+5_f64); + assert_approx_eq!(-4.33993e+13, sim_result_gradient[1], 1e+8_f64); + assert_approx_eq!(-4.33993e+13, sim_result_gradient[2], 1e+8_f64); } } diff --git a/src/output/file.rs b/src/output/file.rs index e776c1d2..a2fc601c 100644 --- a/src/output/file.rs +++ b/src/output/file.rs @@ -40,11 +40,11 @@ pub struct FileOutputPlugin phantom_f: PhantomData, phantom_a: PhantomData } -impl FileOutputPlugin - where +impl FileOutputPlugin + where C: Component + Clone, A: Component, - F: Format> + F: Format> { pub fn new(file_name: String, interval: u64) -> FileOutputPlugin { @@ -53,13 +53,13 @@ impl FileOutputPlugin interval, phantom_a: PhantomData, phantom_c: PhantomData, - phantom_f: PhantomData + phantom_f: PhantomData } } } -impl Plugin for FileOutputPlugin -where +impl Plugin for FileOutputPlugin +where C: Component + Clone + Sync + Send + 'static, A: Component + Sync + Send + 'static, F: Format> + Sync + Send + 'static