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())));

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())));

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())));

Returns the display string of the primitive.

Arguments

  • id - &str containing the ID to view

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.view("loop1");

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 modify
  • radius 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 modify
  • position 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 modify
  • length 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 modify
  • thickness 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 modify
  • thickness 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 AxialSystem
  • r radial position relative to AxialSystem
  • 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_axial(&[2.0,0.1],&1e-16);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.