Struct rustycoils::AxialSystem [−][src]
pub struct AxialSystem { /* fields omitted */ }
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
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]);
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();
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())));
pub 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())));
pub 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())));
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())));
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())));
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();
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();
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();
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())));
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(()));
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())));
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())));
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(()));
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);
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
Auto Trait Implementations
impl RefUnwindSafe for AxialSystem
impl Send for AxialSystem
impl Sync for AxialSystem
impl Unpin for AxialSystem
impl UnwindSafe for AxialSystem
Blanket Implementations
Mutably borrows from an owned value. Read more