RowlandTorus

class marxs.design.rowland.RowlandTorus(R, r, **kwargs)[source] [edit on github]

Bases: MarxsElement, Geometry

Torus with y axis as symmetry axis.

Note that the origin of the torus is the focal point, which may or may not be the same as the center of the torus.

Parameters:
Rfloat

Radius of Rowland torus. r determines the radius of the Rowland circle, R is then used to rotate that circle around the axis of symmetry of the torus.

rfloat

Radius of Rowland circle

Define a new MARXS element.

Attributes Summary

display

Dictionary for display specifications, e.g. color.

Methods Summary

normal(xyzw)

Return the gradient vector field.

normal_parametric(theta, phi)

Return the gradient vector field.

parametric(theta, phi)

Parametric description of points on the torus.

parametric_surface(theta, phi, display)

Parametric representation of surface of torus.

quartic(xyz[, transform])

Quartic torus equation.

solve_quartic(origin, v[, transform])

Solve the quartic on the Rowland torus.

xyz_from_radiusangle(radius, angle, start)

Get Cartesian coordinates for radius, angle on the rowland circle.

xyzw2parametric(xyzw[, transform, ...])

Calculate (theta, phi) coordinates for point on torus surface.

Attributes Documentation

display = {'color': (1.0, 0.3, 0.3), 'coo1': array([0.        , 0.10649467, 0.21298933, 0.319484  , 0.42597866,        0.53247333, 0.638968  , 0.74546266, 0.85195733, 0.958452  ,        1.06494666, 1.17144133, 1.27793599, 1.38443066, 1.49092533,        1.59741999, 1.70391466, 1.81040933, 1.91690399, 2.02339866,        2.12989332, 2.23638799, 2.34288266, 2.44937732, 2.55587199,        2.66236666, 2.76886132, 2.87535599, 2.98185065, 3.08834532,        3.19483999, 3.30133465, 3.40782932, 3.51432399, 3.62081865,        3.72731332, 3.83380798, 3.94030265, 4.04679732, 4.15329198,        4.25978665, 4.36628132, 4.47277598, 4.57927065, 4.68576531,        4.79225998, 4.89875465, 5.00524931, 5.11174398, 5.21823864,        5.32473331, 5.43122798, 5.53772264, 5.64421731, 5.75071198,        5.85720664, 5.96370131, 6.07019597, 6.17669064, 6.28318531]), 'coo2': array([0.        , 0.10649467, 0.21298933, 0.319484  , 0.42597866,        0.53247333, 0.638968  , 0.74546266, 0.85195733, 0.958452  ,        1.06494666, 1.17144133, 1.27793599, 1.38443066, 1.49092533,        1.59741999, 1.70391466, 1.81040933, 1.91690399, 2.02339866,        2.12989332, 2.23638799, 2.34288266, 2.44937732, 2.55587199,        2.66236666, 2.76886132, 2.87535599, 2.98185065, 3.08834532,        3.19483999, 3.30133465, 3.40782932, 3.51432399, 3.62081865,        3.72731332, 3.83380798, 3.94030265, 4.04679732, 4.15329198,        4.25978665, 4.36628132, 4.47277598, 4.57927065, 4.68576531,        4.79225998, 4.89875465, 5.00524931, 5.11174398, 5.21823864,        5.32473331, 5.43122798, 5.53772264, 5.64421731, 5.75071198,        5.85720664, 5.96370131, 6.07019597, 6.17669064, 6.28318531]), 'opacity': 0.2, 'shape': 'torus; surface'}

Dictionary for display specifications, e.g. color

Methods Documentation

normal(xyzw)[source] [edit on github]

Return the gradient vector field.

Following the usual conventions, the vector is pointing outwards of the torus volume.

Parameters:
xyzwnp.array of shape (N, 4)

Coordinates of points in euclidean space. The quartic is calculated for those points. All points need to be on the surface of the torus.

Returns:
gradientnp.array

Gradient vector field in euclidean coordinates. One vector corresponds to each input point. The shape of gradient is the same as the shape of xyz.

normal_parametric(theta, phi)[source] [edit on github]

Return the gradient vector field.

Following the usual convention, the vector is pointing outwards of the torus volume.

Parameters:
theta, phi1-d np.arrays

Theta and phi coordinates for points on the torus surface.

Returns:
gradientnp.array

Gradient vector field in homogeneous coordinates. One vector corresponds to each input point. The shape of gradient is the same as the shape of xyz.

parametric(theta, phi)[source] [edit on github]

Parametric description of points on the torus.

This is just another way to obtain the shape of the torus, e.g. for visualization.

Parameters:
thetanp.array

Points on the Rowland circle (specified in rad, where 0 is on the optical axis across from the focal point).

phinp.array

phi rotates the Rowland circle to make up the Rowland torus.

Returns:
xyzwnp.array

Torus coordinates in global homogeneous coordinate system.

parametric_surface(theta, phi, display)[source] [edit on github]

Parametric representation of surface of torus.

In contrast to parametric the input parameters here are 1-d arrays and the functions converts that to a rectangular grid.

Parameters:
thetanp.array

Points on the Rowland circle (specified in rad, where 0 is on the optical axis across from the focal point).

phinp.array

phi rotates the Rowland circle to make up the Rowland torus.

Returns:
xyzwnp.array

Torus coordinates in global homogeneous coordinate system.

quartic(xyz, transform=True)[source] [edit on github]

Quartic torus equation.

Roots of this equation are points on the torus.

Parameters:
xyznp.array of shape (N, 3) or (3)

Coordinates of points in euclidean space. The quartic is calculated for those points.

transformbool

If True transform xyz from the global coordinate system into the local coordinate system of the torus. If this transformation is done in the calling function already, set to

``False``.
Returns:
qnp.array of shape (N) or scalar

Quartic at the input location

solve_quartic(origin, v, transform=True)[source] [edit on github]

Solve the quartic on the Rowland torus.

This method solves the quartic equation for positions on the Rowland Torus, i.e. it intersects a line with the torus. To that end, the location on the line is varied and the root of the quartic is found through numerical optimization.

Parameters:
originnp.array

Origin of line as homogeneous coordinate. This is also used as approximate starting point for the numerical optimization, so it should be reasonably close to the solution.

vnp.array

Direction of the line as homogeneous coordinate.

transformbool

If True transform input from the global coordinate system into the local coordinate system of the torus. If this transformation is done in the calling function already, set to False.

Returns:
coonp.array

Position of intersection as homogeneous coordinate.

xyz_from_radiusangle(radius, angle, start)[source] [edit on github]

Get Cartesian coordinates for radius, angle on the rowland circle.

y, z are calculated from the radius and angle of polar coordinates in a plane; then x is determined from the condition that the point lies on the Rowland circle. The plane is perpendicular to the optical axis that defines the Rowland circle.

Parameters:
radius, anglefloat or np.array of shape (n,)

Polar coordinates in a plane perpendicular to the optical axis (where the optical axis is parallel to the x-axis and goes through the origin of the RowlandTorus. angle=0 coincides with the local y-axis.

startnumber

Starting value for the search. The quartic can have up to four solutions because a line can intersect a torus in four points. The solution found thus depends on where the numerical root solver starts the search.

Returns:
xyznp.array of shape (n, 3)

Euclidean coordinates in the global coordinate system.

xyzw2parametric(xyzw, transform=True, intersectvalid=True)[source] [edit on github]

Calculate (theta, phi) coordinates for point on torus surface.

Parameters:
xyzwnp.array of shape (N, 4)

Coordinates of points on the torus surface in homogeneous coordinates.

transformbool

If True transform xyz from the global coordinate system into the local coordinate system of the torus. If this transformation is done in the calling function already, set to False.

intersectvalidbool

When r >=R the torus can intersect with itself. At these points, phi is not unique. If intersectvalid is true, those points will be filled with an arbitrarily chosen valid value (0.), otherwise they will be nan.

Returns:
theta, phi: np.array

Parametric representation for all points on the torus.