simsopt.field package
Submodules
simsopt.field.biotsavart module
- class simsopt.field.biotsavart.BiotSavart(coils)
Bases:
simsoptpp.BiotSavart
,simsopt.field.magneticfield.MagneticField
Computes the MagneticField induced by a list of closed curves \(\Gamma_k\) with electric currents \(I_k\). The field is given by
\[B(\mathbf{x}) = \frac{\mu_0}{4\pi} \sum_{k=1}^{n_\mathrm{coils}} I_k \int_0^1 \frac{(\Gamma_k(\phi)-\mathbf{x})\times \Gamma_k'(\phi)}{\|\Gamma_k(\phi)-\mathbf{x}\|^3} d\phi\]where \(\mu_0=4\pi 10^{-7}\) is the magnetic constant.
- Parameters
coils – A list of
simsopt.field.coil.Coil
objects.
- A(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_and_dB_vjp(v, vgrad)
Same as
simsopt.geo.biotsavart.BiotSavart.B_vjp
but returns the vector Jacobian product for \(B\) and \(\nabla B\), i.e. it returns\[\{ \sum_{i=1}^{n} \mathbf{v}_i \cdot \partial_{\mathbf{c}_k} \mathbf{B}_i \}_k, \{ \sum_{i=1}^{n} {\mathbf{v}_\mathrm{grad}}_i \cdot \partial_{\mathbf{c}_k} \nabla \mathbf{B}_i \}_k.\]
- B_cyl(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- B_vjp(v)
Assume the field was evaluated at points \(\mathbf{x}_i, i\in \{1, \ldots, n\}\) and denote the value of the field at those points by \(\{\mathbf{B}_i\}_{i=1}^n\). These values depend on the shape of the coils, i.e. on the dofs \(\mathbf{c}_k\) of each coil. This function returns the vector Jacobian product of this dependency, i.e.
\[\{ \sum_{i=1}^{n} \mathbf{v}_i \cdot \partial_{\mathbf{c}_k} \mathbf{B}_i \}_k.\]
- GradAbsB(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- property coils
- compute(self: simsoptpp.BiotSavart, arg0: int) None
- compute_A(compute_derivatives=0)
Compute the potential of a BiotSavart field
\[A(\mathbf{x}) = \frac{\mu_0}{4\pi} \sum_{k=1}^{n_\mathrm{coils}} I_k \int_0^1 \frac{\Gamma_k'(\phi)}{\|\Gamma_k(\phi)-\mathbf{x}\|} d\phi\]as well as the derivatives of A if requested.
- d2A_by_dXdX(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdcoilcurrents(compute_derivatives=1)
- d3B_by_dXdXdcoilcurrents(compute_derivatives=2)
- dA_by_dX(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dcoilcurrents(compute_derivatives=0)
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fieldcache_get_or_create(self: simsoptpp.BiotSavart, arg0: str, arg1: List[int]) numpy.ndarray[numpy.float64]
- fieldcache_get_status(self: simsoptpp.BiotSavart, arg0: str) bool
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.BiotSavart) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.BiotSavart) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.BiotSavart, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.BiotSavart, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.BiotSavart, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
simsopt.field.coil module
- class simsopt.field.coil.Coil(curve, current)
Bases:
simsoptpp.Coil
,simsopt._core.graph_optimizable.Optimizable
A
Coil
combines aCurve
and aCurrent
and is used as input for aBiotSavart
field.- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property current
Get the underlying current.
- property curve
Get the underlying curve.
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- vjp(v_gamma, v_gammadash, v_current)
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.coil.Current(current)
Bases:
simsoptpp.Current
,simsopt._core.graph_optimizable.Optimizable
An optimizable object that wraps around a single scalar degree of freedom. It represents the electric current in a coil, or in a set of coils that are constrained to use the same current.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_dofs(self: simsoptpp.Current) numpy.ndarray[numpy.float64]
Get the current.
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- get_value(self: simsoptpp.Current) float
Get the current.
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_dofs(self: simsoptpp.Current, arg0: numpy.ndarray[numpy.float64]) None
Set the current.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- vjp(v_current)
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.coil.ScaledCurrent(basecurrent, scale)
Bases:
simsoptpp.ScaledCurrent
,simsopt._core.graph_optimizable.Optimizable
Scales
Current
by a factor. To be used for example to flip currents for stellarator symmetric coils.- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- get_value(self: simsoptpp.ScaledCurrent) float
Get the current.
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- property scale
Get the scaling factor.
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- vjp(v_current)
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- simsopt.field.coil.coils_via_symmetries(curves, currents, nfp, stellsym)
Take a list of
n
curves and returnn * nfp * (1+int(stellsym))
Coil
objects obtained by applying rotations and flipping corresponding tonfp
fold rotational symmetry and optionally stellarator symmetry.
simsopt.field.magneticfield module
- class simsopt.field.magneticfield.MagneticField(**kwargs)
Bases:
simsoptpp.MagneticField
,simsopt._core.graph_optimizable.Optimizable
Generic class that represents any magnetic field from which each magnetic field class inherits. The usage of
MagneticField
is as follows:bfield = BiotSavart(coils, currents) # An instance of a MagneticField points = ... # points is a (n, 3) numpy array bfield.set_points(points) B = bfield.B() # returns the Magnetic field at `points` dA = bfield.dA_by_dX() # returns the gradient of the potential of the field at `points`
MagneticField
has a cache to avoid repeated calculations. To clear this cache manually, call the clear_cached_properties() function. The cache is automatically cleared whenset_points
is called or one of the dependencies changes.- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfield.MagneticFieldMultiply(scalar, Bfield)
Bases:
simsopt.field.magneticfield.MagneticField
Class used to multiply a magnetic field by a scalar. It takes as input a MagneticField class and a scalar and multiplies B, A and their derivatives by that value.
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfield.MagneticFieldSum(Bfields)
Bases:
simsopt.field.magneticfield.MagneticField
Class used to sum two or more magnetic field together. It can either be called directly with a list of magnetic fields given as input and outputing another magnetic field with B, A and its derivatives added together or it can be called by summing magnetic fields classes as Bfield1 + Bfield1
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- B_vjp(v)
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
simsopt.field.magneticfieldclasses module
- class simsopt.field.magneticfieldclasses.ChebyshevInterpolationRule
Bases:
simsoptpp.ChebyshevInterpolationRule
- property degree
The degree of the polynomial. The number of interpolation points in degree+1.
- class simsopt.field.magneticfieldclasses.CircularCoil(r0=0.1, center=[0, 0, 0], I=159154.94309189534, normal=[0, 0])
Bases:
simsopt.field.magneticfield.MagneticField
Magnetic field created by a single circular coil evaluated using analytical functions, including complete elliptic integrals of the first and second kind. As inputs, it takes the radius of the coil (r0), its center, current (I) and its normal vector [either spherical angle components (normal=[theta,phi]) or (x,y,z) components of a vector (normal=[x,y,z])]).
- Parameters
r0 – radius of the coil
center – point at the coil center
I – current of the coil in Ampere’s
normal – if list with two values treats it as spherical angles theta and phi of the normal vector to the plane of the coil centered at the coil center, if list with three values treats it a vector
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfieldclasses.Dommaschk(mn=[[0, 0]], coeffs=[[0, 0]])
Bases:
simsopt.field.magneticfield.MagneticField
Vacuum magnetic field created by an explicit representation of the magnetic field scalar potential as proposed by W. Dommaschk (1986), Computer Physics Communications 40, 203-218. As inputs, it takes the arrays for the harmonics m, n and its corresponding coefficients.
- Parameters
m – first harmonic array
n – second harmonic array
coeffs – coefficient for Vml for each of the ith index of the harmonics m and n
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfieldclasses.InterpolatedField(field, degree, rrange, phirange, zrange, extrapolate=True, nfp=1, stellsym=False)
Bases:
simsoptpp.InterpolatedField
,simsopt.field.magneticfield.MagneticField
This field takes an existing field and interpolates it on a regular grid in \(r,\phi,z\). This resulting interpolant can then be evaluated very quickly.
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __init__(field, degree, rrange, phirange, zrange, extrapolate=True, nfp=1, stellsym=False)
- Parameters
field – the underlying
simsopt.field.magneticfield.MagneticField
to be interpolated.degree – the degree of the piecewise polynomial interpolant.
rrange – a 3-tuple of the form
(rmin, rmax, nr)
. This mean that the interval \([rmin, rmax]\) is split intonr
many subintervals.phirange – a 3-tuple of the form
(phimin, phimax, nphi)
.zrange – a 3-tuple of the form
(zmin, zmax, nz)
.extrapolate – whether to extrapolate the field when evaluate outside the integration domain or to throw an error.
nfp – Whether to exploit rotational symmetry. In this case any angle is always mapped into the interval \([0, 2\pi/\mathrm{nfp})\), hence it makes sense to use
phimin=0
andphimax=2*np.pi/nfp
.stellsym – Whether to exploit stellarator symmetry. In this case
z
is always mapped to be positive, hence it makes sense to usezmin=0
.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- estimate_error_B(self: simsoptpp.InterpolatedField, arg0: int) Tuple[float, float]
- estimate_error_GradAbsB(self: simsoptpp.InterpolatedField, arg0: int) Tuple[float, float]
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- property phi_range
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- property r_range
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- property rule
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, h=0.1)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- property z_range
- class simsopt.field.magneticfieldclasses.PoloidalField(R0, B0, q)
Bases:
simsopt.field.magneticfield.MagneticField
Magnetic field purely in the poloidal direction, that is, in the theta direction of a poloidal-toroidal coordinate system. Its modulus is given by B = B0 * r / (R0 * q) so that, together with the toroidal field, it creates a safety factor equals to q
- Parameters
B0 – modulus of the magnetic field at R0
R0 – major radius of the magnetic axis
q – safety factor/pitch angle of the magnetic field lines
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfieldclasses.Reiman(iota0=0.15, iota1=0.38, k=[6], epsilonk=[0.01], m0=1)
Bases:
simsopt.field.magneticfield.MagneticField
Magnetic field model in section 5 of Reiman and Greenside, Computer Physics Communications 43 (1986) 157—167. This field allows for an analytical expression of the magnetic island width that can be used for island optimization. However, the field is not completely physical as it does not have nested flux surfaces.
- Parameters
iota0 – unperturbed rotational transform
iota1 – unperturbed global magnetic shear
k – integer array specifying the Fourier modes used
epsilonk – coefficient of the Fourier modes
m0 – toroidal symmetry parameter (normally m0=1)
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfieldclasses.ScalarPotentialRZMagneticField(PhiStr)
Bases:
simsopt.field.magneticfield.MagneticField
Vacuum magnetic field as a solution of B = grad(Phi) where Phi is the magnetic field scalar potential. It takes Phi as an input string, which should contain an expression involving the standard cylindrical coordinates (R, phi, Z) Example: ScalarPotentialRZMagneticField(“2*phi”) yields a magnetic field B = grad(2*phi) = (0,2/R,0). Note: this function needs sympy.
- Parameters
PhiStr – string containing vacuum scalar potential expression as a function of R, Z and phi
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
- class simsopt.field.magneticfieldclasses.ToroidalField(R0, B0)
Bases:
simsopt.field.magneticfield.MagneticField
Magnetic field purely in the toroidal direction, that is, in the phi direction with (R,phi,Z) the standard cylindrical coordinates. Its modulus is given by B = B0*R0/R where R0 is the first input and B0 the second input to the function.
- Parameters
B0 – modulus of the magnetic field at R0
R0 – radius of normalization
- A(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic potential (in cartesian coordinates). Denoting the indices by i and l, the result contains A_l(x_i).
- A_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As A, but returns a reference to the array (this array should be read only).
- AbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 1) array containing the absolute value of the magnetic field (in cartesian coordinates).
- AbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As AbsB, but returns a reference to the array (this array should be read only).
- B(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the magnetic field (in cartesian coordinates). Denoting the indices by i and l, the result contains B_l(x_i).
- B_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Return a (npoints, 3) array containing the magnetic field (in cylindrical coordinates) (the order is \((B_r, B_\phi, B_z)\)).
- B_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B_cyl, but returns a reference to the array (this array should be read only).
- B_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As B, but returns a reference to the array (this array should be read only).
- GradAbsB(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3) array containing the gradient of the absolute value of the magnetic field (in cartesian coordinates).
- GradAbsB_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
- GradAbsB_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As GradAbsB, but returns a reference to the array (this array should be read only).
- __add__(other)
Add two magnetic fields.
- __eq__(other: simsopt._core.graph_optimizable.Optimizable) bool
Checks the equality condition
- Parameters
other – Another object of subclass of Optimizable
Returns: True only if both are the same objects.
- __mul__(other)
Multiply a field with a scalar.
- __rmul__(other)
Multiply a field with a scalar.
- _add_child(child: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as child. All the required processing of the dependencies is done in the child node. This method is used mainly to maintain 2-way link between parent and child.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _get_ancestors() list[Optimizable]
Get all the ancestors of the current Optimizable object
- Returns
List of Optimizable objects that are parents of current Optimizable objects
- _remove_child(other: simsopt._core.graph_optimizable.Optimizable) None
Remove the specific Optimizable object from the children list.
- Parameters
child – Direct dependent (child) of the Optimizable object
- _update_free_dof_size_indices() None
Updates the DOFs lengths for the Optimizable object as well as those of the descendent (dependent) Optimizable objects.
Call this function whenever DOFs are fixed or unfixed or when parents are added/deleted. Recursively calls the same function in children
- _update_full_dof_size_indices() None
Updates the full DOFs lengths for this instance and those of the children.
Call this function whenever parents are added or removed. Recursively calls the same function in children.
- add_parent(index: int, other: simsopt._core.graph_optimizable.Optimizable) None
Adds another Optimizable object as parent at specified index.
- Parameters
int – Index of the parent’s list
other – Another Optimizable object to be added as parent
- add_return_fn(child: simsopt._core.graph_optimizable.Optimizable, fn: Union[str, Callable]) None
Add return function to the list of the return functions called by the child Optimizable object
- Parameters
child – an Optimizable object that is direct dependent of the current Optimizable instance
fn – method of the Optimizable object needed by the child
- append_parent(other: simsopt._core.graph_optimizable.Optimizable) None
Appends another Optimizable object to parents list
- Parameters
other – New parent Optimizable object
- property bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- clear_cached_properties()
Clear the cache.
- d2A_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the hessian of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j A_l(x_i).
- d2A_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2A_by_dXdX, but returns a reference to the array (this array should be read only).
- d2B_by_dXdX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3, 3) array containing the hessian of magnetic field (in cartesian coordinates). Denoting the indices by i, j, k and l, the result contains partial_kpartial_j B_l(x_i).
- d2B_by_dXdX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As d2B_by_dXdX, but returns a reference to the array (this array should be read only).
- dA_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of the magnetic potential (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j A_l(x_i).
- dA_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dA_by_dX, but returns a reference to the array (this array should be read only).
- dB_by_dX(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Returns a (npoints, 3, 3) array containing the gradient of magnetic field (in cartesian coordinates). Denoting the indices by i, j and l, the result contains partial_j B_l(x_i).
- dB_by_dX_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As dB_by_dX, but returns a reference to the array (this array should be read only).
- property dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with the current Optimizable object and those of its ancestors
- property dof_size: numbers.Integral
Total number of free DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current and ancestors Optimizable objects are free or not
- fix(key: Union[numbers.Integral, str]) None
Set the fixed attribute for the given degree of freedom.
- Parameters
key – DOF identifier
- fix_all() None
Set the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property full_dof_size: numbers.Integral
Total number of all (free and fixed) DOFs associated with the Optimizable object as well as parent Optimizable objects.
- property full_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of all the DOFs associated with the current Optimizable object and those of its ancestors
- get(key: Union[numbers.Integral, str]) numbers.Real
Get the value of specified DOF Even fixed dofs can be obtained individually.
- Parameters
key – DOF identifier
- get_parent_return_fns_list() List[List[Callable]]
Get a list of the funcs returned by the parents as list of lists
- Returns
The funcs returned by all the parents of the Optimizable object
- get_points_cart(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cartesian coordinates.
- get_points_cart_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cart, but returns a reference to the array (this array should be read only).
- get_points_cyl(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
Get the point where the field should be evaluated in cylindrical coordinates (the order is \((r, \phi, z)\)).
- get_points_cyl_ref(self: simsoptpp.MagneticField) numpy.ndarray[numpy.float64]
As get_points_cyl, but returns a reference to the array (this array should be read only).
- get_return_fn_list() List[List[Callable]]
Gets return functions from this Optimizable object used by all the child Optimizable objects
- Returns
List of methods that return a value when the current Optimizable object is called from the children.
- get_return_fn_names() List[str]
Return the names of the functions that could be used as objective functions.
- Returns
List of function names that could be used as objective functions
- get_return_fns(child: simsopt._core.graph_optimizable.Optimizable) List[Callable]
Gets return functions from this Optimizable object used by the child Optimizable object
- Parameters
child – Dependent Optimizable object
- Returns
List of methods that return a value when the current Optimizable object is called from the child
- invalidate_cache(self: simsoptpp.MagneticField) None
Clear the cache. Called automatically after each call to set_points[…].
- is_fixed(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is fixed
- Parameters
key – DOF identifier
- is_free(key: Union[numbers.Integral, str]) bool
Checks if the specified dof is free
- Parameters
key – DOF identifier
- property local_bounds: Tuple[Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]], Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]]
Lower and upper bounds of the free DOFs associated with this Optimizable object
- property local_dof_names: Union[Sequence[str], nptyping.types._ndarray.NDArray[None, nptyping.types._unicode.Unicode]]
Names (Identifiers) of the DOFs associated with this Optimizable object
- property local_dof_size: numbers.Integral
Number of free DOFs associated with the Optimizable object.
- Returns
Number of free DOFs associated with the Optimizable object.
- property local_dofs_free_status: Union[Sequence[bool], nptyping.types._ndarray.NDArray[None, nptyping.types._bool.Bool]]
Boolean array denoting whether the DOFs associated with the current Optimizable object are free or not
- property local_full_dof_size: numbers.Integral
Number of all (free and fixed) DOFs associated with the Optimizable object.
- Returns
Total number of free and fixed DOFs associated with the Optimizable object.
- property local_full_x
Numeric values of all DOFs associated with this Optimizable object
- property local_lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with this Optimizable object
- property local_upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with this Optimizable object
- property local_x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with this Optimizable object
- property lower_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Lower bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property parent_return_fns_no: int
Compute the total number of the return funcs of all the parents of the Optimizable object
- Returns
The total number of the return funcs of the Optimizable object’s parents.
- pop_parent(index: int = - 1) simsopt._core.graph_optimizable.Optimizable
Removes the parent Optimizable object at specified index.
- Parameters
index – Index of the list of the parents
- Returns
The removed parent Optimizable object
- recompute_bell(parent=None)
Function to be called whenever new DOFs input is given or if the parent Optimizable’s data changed, so the output from the current Optimizable object is invalid.
This method gets called by various DOF setters. If only the local DOFs of an object are being set, the recompute_bell method is called in that object and also in the descendent objects that have a dependency on the object, whose local DOFs are being changed. If gloabl DOFs of an object are being set, the recompute_bell method is called in the object, ancestors of the object, as well as the descendents of the object.
Need to be implemented by classes that provide a dof_setter for external handling of DOFs.
- remove_parent(other: simsopt._core.graph_optimizable.Optimizable)
Removes the specified Optimizable object from the list of parents.
- Parameters
other – The Optimizable object to be removed from the list of parents
- return_fn_map = NotImplemented
- set(key: Union[numbers.Integral, str], new_val: numbers.Real) None
Update the value held the specified DOF. Even fixed dofs can be set this way
- Parameters
key – DOF identifier
new_val – New value of the DOF
- set_points(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Shorthand for set_points_cart.
- set_points_cart(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cartesian coordinates.
- set_points_cyl(self: simsoptpp.MagneticField, arg0: numpy.ndarray[numpy.float64]) simsoptpp.MagneticField
Set the points where to evaluate the magnetic fields, in cylindrical coordinates (the order is \((r, \phi, z)\)).
- to_vtk(filename, nr=10, nphi=10, nz=10, rmin=1.0, rmax=2.0, zmin=- 0.5, zmax=0.5)
Export the field evaluated on a regular grid for visualisation with e.g. Paraview.
- unfix(key: Union[numbers.Integral, str]) None
Unset the fixed attribute for the given degree of freedom
- Parameters
key – DOF identifier
- unfix_all() None
Unset the ‘fixed’ attribute for all degrees of freedom associated with the current Optimizable object.
- property upper_bounds: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Upper bounds of the free DOFs associated with the current Optimizable object and those of its ancestors
- property x: Union[Sequence[numbers.Real], nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]]]
Numeric values of the free DOFs associated with the current Optimizable object and those of its ancestors
simsopt.field.sampling module
- simsopt.field.sampling.draw_uniform_on_curve(curve, nsamples, safetyfactor=10)
Uses rejection sampling to sample points on a curve. Warning: assumes that the underlying quadrature points on the Curve are uniformly distributed.
- Parameters
curve – The
simsopt.geo.curve.Curve
to spawn the particles on.nsamples – number of samples.
safetyfactor – how many more samples than
nsamples
to generate for rejection/acceptance.
- simsopt.field.sampling.draw_uniform_on_surface(surface, nsamples, safetyfactor=10)
Uses rejection sampling to sample points on a surface. Warning: assumes that the underlying quadrature points on the surface are uniformly distributed.
- Parameters
surface – The
simsopt.geo.surface.Surface
to spawn the particles on.nsamples – number of samples.
safetyfactor – how many more samples than
nsamples
to generate for rejection/acceptance.
simsopt.field.tracing module
- class simsopt.field.tracing.IterationStoppingCriterion
Bases:
simsoptpp.IterationStoppingCriterion
Stop the iteration once the maximum number of iterations is reached.
- class simsopt.field.tracing.LevelsetStoppingCriterion(classifier)
Bases:
simsoptpp.LevelsetStoppingCriterion
Based on a scalar function \(f:R^3\to R\), this criterion checks whether \(f(x, y, z) < 0\) and stops the iteration once this is true.
The idea is to use this for example with signed distance functions to a surface.
- simsopt.field.tracing.compute_fieldlines(field, R0, Z0, tmax=200, tol=1e-07, phis=[], stopping_criteria=[], comm=None)
Compute magnetic field lines by solving
\[[\dot x, \dot y, \dot z] = B(x, y, z)\]- Parameters
field – the magnetic field \(B\)
R0 – list of radial components of initial points
Z0 – list of vertical components of initial points
tmax – for how long to trace. will do roughly |B|*tmax/(2*pi*r0) revolutions of the device
tol – tolerance for the adaptive ode solver
phis – list of angles in [0, 2pi] for which intersection with the plane corresponding to that phi should be computed
stopping_criteria – list of stopping criteria, mostly used in combination with the
LevelsetStoppingCriterion
accessed viasimsopt.field.tracing.SurfaceClassifier
.
- Returns: 2 element tuple containing
res_tys
:A list of numpy arrays (one for each particle) describing the solution over time. The numpy array is of shape (ntimesteps, 4). Each row contains the time and the position, i.e.`[t, x, y, z]`.
res_phi_hits
:A list of numpy arrays (one for each particle) containing information on each time the particle hits one of the phi planes or one of the stopping criteria. Each row of the array contains [time, idx, x, y, z], where idx tells us which of the phis or stopping_criteria was hit. If idx>=0, then phis[int(idx)] was hit. If idx<0, then stopping_criteria[int(-idx)-1] was hit.
- simsopt.field.tracing.compute_gc_radius(m, vperp, q, absb)
Computes the gyro radius of a particle in a field with strenght
absb`
, that isr=m*vperp/(abs(q)*absb)
.
- simsopt.field.tracing.gc_to_fullorbit_initial_guesses(field, xyz_inits, speed_pars, speed_total, m, q, eta=0)
Takes in guiding center positions
xyz_inits
as well as a parallel speedsspeed_pars
and total velocitiesspeed_total
to compute orbit positions for a full orbit calculation that matches the given guiding center. The phase angle can be controll via the eta parameter
- simsopt.field.tracing.parallel_loop_bounds(comm, n)
Split up an array [0, 1, …, n-1] across an mpi communicator. Example: n = 8, comm with size=2 will return (0, 4) on core 0, (4, 8) on core 1, meaning that the array is split up as [0, 1, 2, 3] + [4, 5, 6, 7].
- simsopt.field.tracing.particles_to_vtk(res_tys, filename)
Export particle tracing or field lines to a vtk file. Expects that the xyz positions can be obtained by
xyz[:, 1:4]
.
- simsopt.field.tracing.plot_poincare_data(fieldlines_phi_hits, phis, filename, mark_lost=False, aspect='equal', dpi=300)
Create a poincare plot. Usage:
phis = np.linspace(0, 2*np.pi/nfp, nphis, endpoint=False) res_tys, res_phi_hits = compute_fieldlines( bsh, R0, Z0, tmax=1000, phis=phis, stopping_criteria=[]) plot_poincare_data(res_phi_hits, phis, '/tmp/fieldlines.png')
Requires matplotlib to be installed.
- simsopt.field.tracing.trace_particles(field: simsopt.field.magneticfield.MagneticField, xyz_inits: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]], parallel_speeds: nptyping.types._ndarray.NDArray[None, nptyping.types._number.Float[float, numpy.floating]], tmax=0.0001, mass=6.69509884346e-27, charge=3.204353268e-19, Ekin=5.639661751679999e-13, tol=1e-09, comm=None, phis=[], stopping_criteria=[], mode='gc_vac', forget_exact_path=False, phase_angle=0)
Follow particles in a magnetic field.
In the case of
mod='full'
we solve\[[\ddot x, \ddot y, \ddot z] = \frac{q}{m} [\dot x, \dot y, \dot z] \times B\]in the case of
mod='gc_vac'
we solve the guiding center equations under the assumption \(\nabla p=0\), that is\[\begin{split}[\dot x, \dot y, \dot z] &= v_{||}\frac{B}{|B|} + \frac{m}{q|B|^3} (0.5v_\perp^2 + v_{||}^2) B\times \nabla(|B|)\\ \dot v_{||} &= -\mu (B \cdot \nabla(|B|))\end{split}\]where \(v_\perp = 2\mu|B|\). See equations (12) and (13) of [Guiding Center Motion, H.J. de Blank, https://doi.org/10.13182/FST04-A468].
- Parameters
field – The magnetic field \(B\).
xyz_inits – A (nparticles, 3) array with the initial positions of the particles.
parallel_speeds – A (nparticles, ) array containing the speed in direction of the B field for each particle.
tmax – integration time
mass – particle mass in kg, defaults to the mass of an alpha particle
charge – charge in Coulomb, defaults to the charge of an alpha particle
Ekin – kinetic energy in Joule, defaults to 3.52MeV
tol – tolerance for the adaptive ode solver
comm – MPI communicator to parallelize over
phis – list of angles in [0, 2pi] for which intersection with the plane corresponding to that phi should be computed
stopping_criteria – list of stopping criteria, mostly used in combination with the
LevelsetStoppingCriterion
accessed viasimsopt.field.tracing.SurfaceClassifier
.mode – how to trace the particles. options are gc: general guiding center equations, gc_vac: simplified guiding center equations for the case \(\nabla p=0\), full: full orbit calculation (slow!)
forget_exact_path – return only the first and last position of each particle for the
res_tys
. To be used when only res_phi_hits is of interest or one wants to reduce memory usage.phase_angle – the phase angle to use in the case of full orbit calculations
- Returns: 2 element tuple containing
res_tys
:A list of numpy arrays (one for each particle) describing the solution over time. The numpy array is of shape (ntimesteps, M) with M depending on the
mode
. Each row contains the time and the state. So for mode=’gc’ and mode=’gc_vac’ the state consists of the xyz position and the parallel speed, hence each row contains [t, x, y, z, v_par]. For mode=’full’, the state consists of position and velocity vector, i.e. each row contains [t, x, y, z, vx, vy, vz].
res_phi_hits
:A list of numpy arrays (one for each particle) containing information on each time the particle hits one of the phi planes or one of the stopping criteria. Each row of the array contains [time] + [idx] + state, where idx tells us which of the phis or stopping_criteria was hit. If idx>=0, then phis[int(idx)] was hit. If idx<0, then stopping_criteria[int(-idx)-1] was hit.
- simsopt.field.tracing.trace_particles_starting_on_curve(curve, field, nparticles, tmax=0.0001, mass=6.69509884346e-27, charge=3.204353268e-19, Ekin=5.639661751679999e-13, tol=1e-09, comm=None, seed=1, umin=- 1, umax=1, phis=[], stopping_criteria=[], mode='gc_vac', forget_exact_path=False, phase_angle=0)
Follows particles spawned at random locations on the magnetic axis with random pitch angle. See
simsopt.field.tracing.trace_particles
for the governing equations.- Parameters
curve – The
simsopt.geo.curve.Curve
to spawn the particles on. Uses rejection sampling to sample points on the curve. Warning: assumes that the underlying quadrature points on the Curve are uniformly distributed.field – The magnetic field \(B\).
nparticles – number of particles to follow.
tmax – integration time
mass – particle mass in kg, defaults to the mass of an alpha particle
charge – charge in Coulomb, defaults to the charge of an alpha particle
Ekin – kinetic energy in Joule, defaults to 3.52MeV
tol – tolerance for the adaptive ode solver
comm – MPI communicator to parallelize over
seed – random seed
umin – the parallel speed is defined as
v_par = u * speed_total
whereu
is drawn uniformly in[umin, umax]
umax – see
umin
phis – list of angles in [0, 2pi] for which intersection with the plane corresponding to that phi should be computed
stopping_criteria – list of stopping criteria, mostly used in combination with the
LevelsetStoppingCriterion
accessed viasimsopt.field.tracing.SurfaceClassifier
.mode – how to trace the particles. options are gc: general guiding center equations, gc_vac: simplified guiding center equations for the case \(\nabla p=0\), full: full orbit calculation (slow!)
forget_exact_path – return only the first and last position of each particle for the
res_tys
. To be used when only res_phi_hits is of interest or one wants to reduce memory usage.phase_angle – the phase angle to use in the case of full orbit calculations
Returns: see
simsopt.field.tracing.trace_particles
- simsopt.field.tracing.trace_particles_starting_on_surface(surface, field, nparticles, tmax=0.0001, mass=6.69509884346e-27, charge=3.204353268e-19, Ekin=5.639661751679999e-13, tol=1e-09, comm=None, seed=1, umin=- 1, umax=1, phis=[], stopping_criteria=[], mode='gc_vac', forget_exact_path=False, phase_angle=0)
Follows particles spawned at random locations on the magnetic axis with random pitch angle. See
simsopt.field.tracing.trace_particles
for the governing equations.- Parameters
surface – The
simsopt.geo.surface.Surface
to spawn the particles on. Uses rejection sampling to sample points on the curve. Warning: assumes that the underlying quadrature points on the Curve as uniformly distributed.field – The magnetic field \(B\).
nparticles – number of particles to follow.
tmax – integration time
mass – particle mass in kg, defaults to the mass of an alpha particle
charge – charge in Coulomb, defaults to the charge of an alpha particle
Ekin – kinetic energy in Joule, defaults to 3.52MeV
tol – tolerance for the adaptive ode solver
comm – MPI communicator to parallelize over
seed – random seed
umin – the parallel speed is defined as
v_par = u * speed_total
whereu
is drawn uniformly in[umin, umax]
.umax – see
umin
phis – list of angles in [0, 2pi] for which intersection with the plane corresponding to that phi should be computed
stopping_criteria – list of stopping criteria, mostly used in combination with the
LevelsetStoppingCriterion
accessed viasimsopt.field.tracing.SurfaceClassifier
.mode – how to trace the particles. options are gc: general guiding center equations, gc_vac: simplified guiding center equations for the case \(\nabla p=0\), full: full orbit calculation (slow!)
forget_exact_path – return only the first and last position of each particle for the
res_tys
. To be used when only res_phi_hits is of interest or one wants to reduce memory usage.phase_angle – the phase angle to use in the case of full orbit calculations
Returns: see
simsopt.field.tracing.trace_particles