pub struct AxialSystem { /* private fields */ }
Expand description
Structure which defines a system of primitives with a shared symmetry axis.
This allows for large number of primitive shapes to be combined to generate a more complicated magentic field struture. The system is defined by an origin vector and a orientation vector. Currently only orientations along the x,y,z axes and placed at the origin of the global coordinate system are allowed.
individual primitives can be added to the AxialSystem and are stored in a HashMap with String based keys. These keys allow individual primitives to be accessed and modifies. Functions exist to modify individual physical parameters such as radius,length,thickness,position,current. The magnetic field is computed currently by working out the individual magentic field of each primitive individually. TO-DO: include rayon support for parallel compuation of the primitive magnetic fields.
Implementations§
Source§impl AxialSystem
impl AxialSystem
Sourcepub fn new(origin: [f64; 3], orientation: [f64; 3]) -> AxialSystem
pub fn new(origin: [f64; 3], orientation: [f64; 3]) -> AxialSystem
Returns a new AxialSystem
Currently only supports objects located at the origin with their orientation along any of the x,y,z directions and so internally calls the default method.
§Examples
Basic usage:
let axial = AxialSystem::new([0.0,0.0,0.0],[1.0,0.0,0.0]);
Sourcepub fn default() -> AxialSystem
pub fn default() -> AxialSystem
Returns the default AxialSystem
This has the shared symmetry axis located at the global origin (0,0,0) with its symmetry axis along the x axis (1,0,0).
§Examples
Basic usage:
let axial = AxialSystem::default();
Source§impl AxialSystem
impl AxialSystem
Sourcepub fn add_loop(
&mut self,
id: String,
radius: f64,
origin: f64,
current: f64,
) -> Result<(), AxialError>
pub fn add_loop( &mut self, id: String, radius: f64, origin: f64, current: f64, ) -> Result<(), AxialError>
Adds an instance of the ideal loop to the AxialSystem
Provide a unique identifer for the primitive as a String method checks if the identifier is allowed due to either clashing with a reserved word or due to a primitive already sharing the name.
§Examples
Basic usage:
let mut axial = AxialSystem::default();
let result = axial.add_loop("loop1".to_string(),1.0,0.0,1.0);
assert_eq!(result,Ok(()));
let result2 = axial.add_loop("loop1".to_string(),2.0,1.0,1.0);
assert_eq!(result2,Err(AxialError::KeyDuplicateError("loop1".to_string())));
let result3 = axial.add_loop("LOOP".to_string(),2.0,1.0,1.0);
assert_eq!(result3,Err(AxialError::ReservedWordError("LOOP".to_string())));
Sourcepub fn add_annular(
&mut self,
id: String,
radius: f64,
thickness: f64,
origin: f64,
current: f64,
) -> Result<(), AxialError>
pub fn add_annular( &mut self, id: String, radius: f64, thickness: f64, origin: f64, current: f64, ) -> Result<(), AxialError>
Adds an instance of the annular primitive to the AxialSystem
Provide a unique identifer for the primitive as a String method checks if the identifier is allowed due to either clashing with a reserved word or due to a primitive already sharing the name.
§Examples
Basic usage:
let mut axial = AxialSystem::default();
let result = axial.add_annular("annular1".to_string(),1.0,0.1,0.0,1.0);
assert_eq!(result,Ok(()));
let result2 = axial.add_annular("annular1".to_string(),2.0,0.1,1.0,1.0);
assert_eq!(result2,Err(AxialError::KeyDuplicateError("annular1".to_string())));
let result3 = axial.add_annular("ANNULAR".to_string(),2.0,0.1,1.0,1.0);
assert_eq!(result3,Err(AxialError::ReservedWordError("ANNULAR".to_string())));
Sourcepub fn add_thin_solenoid(
&mut self,
id: String,
radius: f64,
length: f64,
origin: f64,
current: f64,
) -> Result<(), AxialError>
pub fn add_thin_solenoid( &mut self, id: String, radius: f64, length: f64, origin: f64, current: f64, ) -> Result<(), AxialError>
Adds an instance of the thin solenoid primitive to the AxialSystem
Provide a unique identifer for the primitive as a String method checks if the identifier is allowed due to either clashing with a reserved word or due to a primitive already sharing the name.
§Examples
Basic usage:
let mut axial = AxialSystem::default();
let result = axial.add_thin_solenoid("solenoid1".to_string(),1.0,10.0,0.0,1.0);
assert_eq!(result,Ok(()));
let result2 = axial.add_thin_solenoid("solenoid1".to_string(),2.0,0.1,1.0,1.0);
assert_eq!(result2,Err(AxialError::KeyDuplicateError("solenoid1".to_string())));
let result3 = axial.add_thin_solenoid("SOLENOID".to_string(),2.0,0.1,1.0,1.0);
assert_eq!(result3,Err(AxialError::ReservedWordError("SOLENOID".to_string())));
Sourcepub fn add_coil_solenoid(
&mut self,
id: String,
radius: f64,
length: f64,
thickness: f64,
origin: f64,
current: f64,
) -> Result<(), AxialError>
pub fn add_coil_solenoid( &mut self, id: String, radius: f64, length: f64, thickness: f64, origin: f64, current: f64, ) -> Result<(), AxialError>
Adds an instance of the coil solenoid primitive to the AxialSystem
Provide a unique identifer for the primitive as a String method checks if the identifier is allowed due to either clashing with a reserved word or due to a primitive already sharing the name.
§Examples
Basic usage:
let mut axial = AxialSystem::default();
let result = axial.add_coil_solenoid("coil1".to_string(),1.0,10.0,0.1,0.0,1.0);
assert_eq!(result,Ok(()));
let result2 = axial.add_coil_solenoid("coil1".to_string(),2.0,10.0,0.1,1.0,1.0);
assert_eq!(result2,Err(AxialError::KeyDuplicateError("coil1".to_string())));
let result3 = axial.add_coil_solenoid("COIL".to_string(),2.0,10.0,0.1,1.0,1.0);
assert_eq!(result3,Err(AxialError::ReservedWordError("COIL".to_string())));
Sourcepub fn remove(&mut self, id: &str) -> Result<(), AxialError>
pub fn remove(&mut self, id: &str) -> Result<(), AxialError>
Removes the primitive matching the provided id.
§Arguments
id
- &str containing the ID to remove
§Examples
let mut axial = AxialSystem::default();
let result = axial.add_loop("loop1".to_string(),1.0,0.0,1.0);
let result_wrong_id = axial.remove("loop2");
assert_eq!(result_wrong_id,Err(AxialError::KeyMissingError("loop2".to_string())));
Source§impl AxialSystem
impl AxialSystem
Source§impl AxialSystem
impl AxialSystem
Sourcepub fn transform_x(&mut self)
pub fn transform_x(&mut self)
Transforms the symmetry axis to point along the x axis
i.e. converts the AxialSystems orientation to (1,0,0)
§Examples
let mut axial = AxialSystem::default();
axial.transform_x();
Sourcepub fn transform_y(&mut self)
pub fn transform_y(&mut self)
Transforms the symmetry axis to point along the y axis
i.e. converts the AxialSystems orientation to (0,1,0)
§Examples
let mut axial = AxialSystem::default();
axial.transform_y();
Sourcepub fn transform_z(&mut self)
pub fn transform_z(&mut self)
Transforms the symmetry axis to point along the z axis
i.e. converts the AxialSystems orientation to (0,0,1)
§Examples
let mut axial = AxialSystem::default();
axial.transform_z();
Source§impl AxialSystem
impl AxialSystem
Sourcepub fn modify_radius(&mut self, id: &str, radius: f64) -> Result<(), AxialError>
pub fn modify_radius(&mut self, id: &str, radius: f64) -> Result<(), AxialError>
Modifies the radius of a given primitive/ set of primitives
Can provide the ID of a single primitive or provide one of the possible reserved keywords to modify a set of primitives
*LOOP
change radius of all loop primitives
*ANNULAR
change radius of all annular primitives
*SOLENOID
change radius of all solenoid primitives
*COILS
change radius of all coil primitives
§Arguments
id
contains the ID of the primitive to modifyradius
new radius of the primitive
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_loop("loop1".to_string(),1.0,0.0,0.0);
let res = axial.modify_radius("loop1",2.0);
assert_eq!(res,Ok(()));
let res = axial.modify_radius("loop2",2.0);
assert_eq!(res,Err(AxialError::KeyMissingError("loop2".to_string())));
Sourcepub fn modify_position(
&mut self,
id: &str,
position: f64,
) -> Result<(), AxialError>
pub fn modify_position( &mut self, id: &str, position: f64, ) -> Result<(), AxialError>
Modifies the position of a given primitive/set of primitives relative to the AxialSystem along the symmetry axis
Can provide the ID of a single primitive or provide one of the possible reserved keywords to modify a set of primitives
*LOOP
change radius of all loop primitives
*ANNULAR
change radius of all annular primitives
*SOLENOID
change radius of all solenoid primitives
*COILS
change radius of all coil primitives
§Arguments
id
contains the ID of the primitive to modifyposition
new position of the primitive
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_loop("loop1".to_string(),1.0,0.0,0.0);
let res = axial.modify_position("loop1",1.0);
assert_eq!(res,Ok(()));
Sourcepub fn modify_length(&mut self, id: &str, length: f64) -> Result<(), AxialError>
pub fn modify_length(&mut self, id: &str, length: f64) -> Result<(), AxialError>
Modifies the length of a given primitive/set of primitives
Can provide the ID of a single primitive or provide one of the possible reserved keywords to modify a set of primitives If the provided ID belongs to a primitive that does not possess length as a parameter returns a AxialError::IncompatiblePrimitiveError
*LOOP
change radius of all loop primitives
*ANNULAR
change radius of all annular primitives
*SOLENOID
change radius of all solenoid primitives
*COILS
change radius of all coil primitives
§Arguments
id
contains the ID of the primitive to modifylength
new position of the primitive
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_thin_solenoid("solenoid1".to_string(),1.0,10.0,0.0,0.0);
let res = axial.modify_length("solenoid1",5.0);
assert_eq!(res,Ok(()));
let res = axial.add_loop("loop1".to_string(),1.0,0.0,0.0);
let res = axial.modify_length("loop1",5.0);
assert_eq!(res,Err(AxialError::IncompatiblePrimitiveError("loop1".to_string(),"LOOP".to_string())));
Sourcepub fn modify_thickness(
&mut self,
id: &str,
thickness: f64,
) -> Result<(), AxialError>
pub fn modify_thickness( &mut self, id: &str, thickness: f64, ) -> Result<(), AxialError>
Modifies the thickness of a given primitive/set of primitives
Can provide the ID of a single primitive or provide one of the possible reserved keywords to modify a set of primitives If the provided ID belongs to a primitive that does not possess length as a parameter returns a AxialError::IncompatiblePrimitiveError
*LOOP
change radius of all loop primitives
*ANNULAR
change radius of all annular primitives
*SOLENOID
change radius of all solenoid primitives
*COILS
change radius of all coil primitives
§Arguments
id
contains the ID of the primitive to modifythickness
new position of the primitive
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_annular("annular1".to_string(),1.0,1.0,0.0,0.0);
let res = axial.modify_thickness("annular1",5.0);
assert_eq!(res,Ok(()));
let res = axial.add_loop("loop1".to_string(),1.0,0.0,0.0);
let res = axial.modify_thickness("loop1",5.0);
assert_eq!(res,Err(AxialError::IncompatiblePrimitiveError("loop1".to_string(),"LOOP".to_string())));
Sourcepub fn modify_current(
&mut self,
id: &str,
current: f64,
) -> Result<(), AxialError>
pub fn modify_current( &mut self, id: &str, current: f64, ) -> Result<(), AxialError>
Modifies the current of a given primitive/set of primitives
Can provide the ID of a single primitive or provide one of the possible reserved keywords to modify a set of primitives
*LOOP
change radius of all loop primitives
*ANNULAR
change radius of all annular primitives
*SOLENOID
change radius of all solenoid primitives
*COILS
change radius of all coil primitives
§Arguments
id
contains the ID of the primitive to modifythickness
new position of the primitive
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_annular("annular1".to_string(),1.0,1.0,0.0,0.0);
let res = axial.modify_current("annular1",5.0);
assert_eq!(res,Ok(()));
Source§impl AxialSystem
impl AxialSystem
Sourcepub fn get_field(&self, pos: [f64; 3], tol: &f64) -> [f64; 3]
pub fn get_field(&self, pos: [f64; 3], tol: &f64) -> [f64; 3]
Computes the magnetic field of the axial system
Takes the position coordinates of the location for which the magentic field is desired. These coordinates are in the global space and not relative to the axial system.
§Arguments
(x,y,z)
tuple containing the x,y,z coordinates.tol
the tolerance at which the series expansion shuold terminate.
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_loop("loop1".to_string(),1.0,0.0,1.0);
let magnetic_field = axial.get_field([0.0,0.0,0.0],&1e-16);
Sourcepub fn get_field_axial(&self, position: &[f64; 2], tol: &f64) -> [f64; 2]
pub fn get_field_axial(&self, position: &[f64; 2], tol: &f64) -> [f64; 2]
Computes the magnetic field of the axial system in relative frame
Takes the position coordinates of the location for which the magentic field is desired. These coordinates are in the global space and not relative to the axial system.
§Arguments
z
axial position relative to AxialSystemr
radial position relative to AxialSystemtol
the tolerance at which the series expansion shuold terminate.
§Examples
let mut axial = AxialSystem::default();
let res = axial.add_loop("loop1".to_string(),1.0,0.0,1.0);
let magnetic_field = axial.get_field_axial(&[2.0,0.1],&1e-16);
Trait Implementations§
Source§impl Clone for AxialSystem
impl Clone for AxialSystem
Source§fn clone(&self) -> AxialSystem
fn clone(&self) -> AxialSystem
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more