mcdc.Surface#

class mcdc.Surface(type_, name, boundary_condition)#

Geometric boundaries of simulation cells.

Surfaces are created with class methods such as PlaneX(), CylinderZ(), and Sphere(). Unary + and - return the corresponding positive and negative half-space Region.

Boundary conditions may be "none", "vacuum", or "reflective". A surface can also undergo piecewise-constant translational motion configured with move().

Examples

Create a vacuum x plane and select its positive half-space:

>>> import numpy as np
>>> import mcdc
>>> plane = mcdc.Surface.PlaneX(x=0.0, boundary_condition="vacuum")
>>> region = +plane

Create a sphere and select its interior:

>>> sphere = mcdc.Surface.Sphere(center=[0.0, 0.0, 0.0], radius=2.0)
>>> interior = -sphere

Create a cylinder parallel to the z axis:

>>> cylinder = mcdc.Surface.CylinderZ(
...     center=[1.0, -1.0],
...     radius=0.5,
... )

Create an oblique plane from its equation coefficients:

>>> oblique = mcdc.Surface.Plane(A=1.0, B=1.0, C=0.0, D=-2.0)

Create a torus with an arbitrary symmetry axis:

>>> torus = mcdc.Surface.Torus(
...     center=[0.0, 0.0, 0.0],
...     axis=[1.0, 1.0, 0.0],
...     R=2.0,
...     r=0.5,
... )

Define piecewise-constant motion for a plane:

>>> moving_plane = mcdc.Surface.PlaneX(x=0.0)
>>> moving_plane.move(
...     velocities=np.array([[1.0, 0.0, 0.0]]),
...     durations=np.array([0.5]),
... )
classmethod ConeX(name: str = '', apex: Sequence[float] = [0.0, 0.0, 0.0], t_sq: float = 1.0, boundary_condition: str = 'none')#

Create a double cone aligned with the x axis.

apex is in cm and t_sq is the squared tangent of the opening half-angle.

classmethod ConeY(name: str = '', apex: Sequence[float] = [0.0, 0.0, 0.0], t_sq: float = 1.0, boundary_condition: str = 'none')#

Create a double cone aligned with the y axis.

apex is in cm and t_sq is the squared tangent of the opening half-angle.

classmethod ConeZ(name: str = '', apex: Sequence[float] = [0.0, 0.0, 0.0], t_sq: float = 1.0, boundary_condition: str = 'none')#

Create a double cone aligned with the z axis.

apex is in cm and t_sq is the squared tangent of the opening half-angle.

classmethod Cylinder(name: str = '', radius: float = 0.0, axis: Sequence[float] = [0.0, 0.0, 1.0], point: Sequence[float] = [0.0, 0.0, 0.0], boundary_condition: str = 'none')#

Create an infinite cylinder with an arbitrary axis.

Parameters:
  • radius (float, optional) – Cylinder radius in cm.

  • axis (sequence of 3 float, optional) – Nonzero vector parallel to the cylinder axis.

  • point (sequence of 3 float, optional) – A point on the cylinder axis, in cm.

classmethod CylinderX(name: str = '', center: Sequence[float] = [0.0, 0.0], radius: float = 0.0, boundary_condition: str = 'none')#

Create an infinite cylinder parallel to the x axis.

center gives [y, z] in cm and radius is in cm.

classmethod CylinderY(name: str = '', center: Sequence[float] = [0.0, 0.0], radius: float = 0.0, boundary_condition: str = 'none')#

Create an infinite cylinder parallel to the y axis.

center gives [x, z] in cm and radius is in cm.

classmethod CylinderZ(name: str = '', center: Sequence[float] = [0.0, 0.0], radius: float = 0.0, boundary_condition: str = 'none')#

Create an infinite cylinder parallel to the z axis.

center gives [x, y] in cm and radius is in cm.

classmethod Plane(name: str = '', A: float = 0.0, B: float = 0.0, C: float = 0.0, D: float = 0.0, boundary_condition: str = 'none')#

Create a general plane A*x + B*y + C*z + D = 0.

The coefficients are normalized internally. (A, B, C) must be a nonzero normal vector.

classmethod PlaneX(name: str = '', x: float = 0.0, boundary_condition: str = 'none')#

Create the plane x = constant.

Parameters:
  • name (str, optional) – User-facing surface name.

  • x (float, optional) – Plane position in cm.

  • boundary_condition ({"none", "vacuum", "reflective"}, optional) – Boundary condition applied when a particle crosses the plane.

classmethod PlaneY(name: str = '', y: float = 0.0, boundary_condition: str = 'none')#

Create the plane y = constant.

Parameters are the surface name, position y in cm, and a boundary_condition of "none", "vacuum", or "reflective".

classmethod PlaneZ(name: str = '', z: float = 0.0, boundary_condition: str = 'none')#

Create the plane z = constant.

Parameters are the surface name, position z in cm, and a boundary_condition of "none", "vacuum", or "reflective".

classmethod Quadric(name: str = '', A: float = 0.0, B: float = 0.0, C: float = 0.0, D: float = 0.0, E: float = 0.0, F: float = 0.0, G: float = 0.0, H: float = 0.0, I: float = 0.0, J: float = 0.0, boundary_condition: str = 'none')#

Create a general second-degree surface.

The coefficients define A*x**2 + B*y**2 + C*z**2 + D*x*y + E*x*z + F*y*z + G*x + H*y + I*z + J = 0.

classmethod Sphere(name: str = '', center: Sequence[float] = [0.0, 0.0, 0.0], radius: float = 0.0, boundary_condition: str = 'none')#

Create a sphere from its center and radius in cm.

classmethod Torus(name: str = '', center: Sequence[float] = [0.0, 0.0, 0.0], axis: Sequence[float] = [0.0, 0.0, 1.0], R: float = 0.0, r: float = 0.0, boundary_condition: str = 'none')#

Create a torus with an arbitrary axis.

Parameters:
  • center (sequence of 3 float, optional) – Torus center in cm.

  • axis (sequence of 3 float, optional) – Nonzero symmetry-axis vector.

  • R (float, optional) – Major radius in cm.

  • r (float, optional) – Minor radius in cm.

classmethod TorusX(name: str = '', A: float = 0.0, B: float = 0.0, C: float = 0.0, R: float = 0.0, r: float = 0.0, boundary_condition: str = 'none')#

Create a torus centered at (A, B, C) and aligned with x.

R is the major radius and r the minor radius, both in cm.

classmethod TorusY(name: str = '', A: float = 0.0, B: float = 0.0, C: float = 0.0, R: float = 0.0, r: float = 0.0, boundary_condition: str = 'none')#

Create a torus centered at (A, B, C) and aligned with y.

R is the major radius and r the minor radius, both in cm.

classmethod TorusZ(name: str = '', A: float = 0.0, B: float = 0.0, C: float = 0.0, R: float = 0.0, r: float = 0.0, boundary_condition: str = 'none')#

Create a torus centered at (A, B, C) and aligned with z.

R is the major radius and r the minor radius, both in cm.

move(velocities, durations)#

Define piecewise-constant translational motion.

Parameters:
  • velocities (array_like, shape (N, 3)) – Velocity vector for each segment in cm/s.

  • durations (array_like, shape (N,)) – Segment durations in seconds. A final stationary segment is appended automatically.