Skip to main content

Usage

Coordinate system​

The z axis is the sputtering axis, x and y complete a right-handed system, and all vectors are given as (x, y, z). There is no unit system — every length in the script has to use the same unit, and it has to be the unit of the histogram coordinates. Angles in the API are in degrees.

Spherical coordinates follow the ISO physics convention: the azimuthal angle is zero at the x axis and increases counter-clockwise when looking from positive z down onto the xy plane.

The four objects of a scenario​

import SRT as SRT
import SRTHelper as SRTHelper

rt = SRT.Raytracer() # the simulation
s = rt.get_substrate() # the part
t = rt.get_trajectory() # how the part moves

These objects carry the whole scenario. Create them once, at the top of the script, and reset them between runs instead of building new ones — especially for concave substrates, where the precomputation is expensive. At the start, neither the substrate nor the trajectory has any content; that is what the following sections fill in.

Substrate​

The substrate is a set of quadrilateral patches generated from a parametric shape:

s.generate_geometry("spherical_lens", {
"n_r": 25, # patches in radial direction
"n_phi": 60, # patches in angular direction
"r_curvature": 120.0,
"r_base": 40.0
})

# Concave shapes need a precomputed self-intersection table
if s.is_concave():
rt.precompute_substrate_intersections()

# Coat from below instead of from above
s.set_sputter_up()

The available shapes are disk, slanted rectangle, spherical lens, aspherical lens, toric lens, inverted spherical lens, bent rectangle and parabolic lens, plus custom triangle meshes. Every shape with its parameters and its exact parametrisation is listed on the Substrates page.

precompute_substrate_intersections() takes some time but prevents rays from passing through another part of a concave substrate. You can omit it for a quick test run, but not for a production result.

s.set_sputter_up() flips the geometry around the trajectory in z direction; everything else keeps its coordinates.

Trajectory​

A straight line, a circular arc, or a list built by hand:

# Straight line
t.generate_line(11, SRT.PhysVector(100.0, 100.0, 100.0),
SRT.PhysVector(200.0, 100.0, 100.0), 90.0)

# Circular arc: samples, radius, start angle, end angle, centre, substrate rotation
t.generate_circle_arc(381, 540.0, -19.0, 19.0, SRT.PhysVector(-232.0, 260.0, 385.0), -19.0)

Both take the number of samples including the start and end point, and the initial substrate orientation in degrees. On a circular arc the substrate keeps its orientation towards the centre of the circle.

For anything else, build the list yourself — each entry is a position plus a rotation:

t.load_from_list([
(SRT.PhysVector(100.0, 100.0, 100.0), 0.0),
(SRT.PhysVector(150.0, 150.0, 100.0), 45.0),
(SRT.PhysVector(200.0, 200.0, 100.0), 90.0),
])

Lists can be generated by normal Python code, so there is no need to write them out by hand. If the trajectory is defined by machine parameters instead of points — turntable RPM, carrier speed — use the helper module, which produces exactly such a list.

Check an unfamiliar trajectory in a viewer before running the raytracer:

t.dump_gmsh("trajectory.pos")

The time resolution is the parameter to check first: too coarse and the deposition shows stripes, too fine and the run takes hours. Halve it until the profile stops changing.

Histogram​

The flux source is the histogram matrix written by DSMC or PICMC. Each line of such a file is one angle combination:

energy_eV theta_deg phi_deg flux_1 .. flux_nx*ny

The first three columns are the energy in eV, the polar angle and the azimuthal angle in degrees. The following nx*ny columns are the sampled flux for each slab of the sampling plane, ordered with the x index running fastest:

i_column = i_x + n_x * i_y

A histogram batch is one source. Several histograms inside a batch are the same source sampled at different z coordinates — the raytracer uses the one closest to the patch it is looking at, which is what you want for strongly curved parts:

batch = rt.add_histogram_batch("Main")
batch.add_histogram_from_file(
"histogram-matrix/histogram_3_Matrix_Ta.txt",
SRT.PhysVector(225.0, 120.0, 380.0), # lower corner of the sampling plane
SRT.PhysVector(525.0, 400.0, 380.0), # upper corner, same z
30, 28, # n_x, n_y — must match the file
90.0, # rotate the plane around z if needed
False # swap x and y if the DSMC axes are swapped
)

d_phi and swap_x_y exist because the histogram files carry no orientation of their own. Check the orientation once with a large flat disk and no mask before trusting a curved result.

Several batches are independent sources and all of them are used. batch.set_inactive() switches one off without deleting it, batch.set_active() brings it back; a new batch is active by default.

Masks​

A mask is a closed polygon in a plane of constant z, built from nodes connected by circular arcs, plus a thickness in sputtering direction. Rays crossing it are discarded.

m = rt.add_mask("Uniformity")
m.set_thickness(4.0)

n0 = m.add_node(SRT.PhysVector(100.0, 0.0, 380.0))
n1 = m.add_node(SRT.PhysVector(0.0, 100.0, 380.0))
n2 = m.add_node(SRT.PhysVector(-100.0, 0.0, 380.0))

m.add_circle_arc(n0, n1, 100.0) # radius of the arc between the two nodes
m.add_circle_arc(n1, n2, 100.0)
m.add_circle_arc(n2, n0, 100.0)

Rules that the code enforces or that silently ruin a result:

  • The mask must be closed, otherwise the inside/outside test is meaningless.
  • The arc radius has to be at least half the distance between its two nodes.
  • A negative radius curves the arc the other way round.
  • A very large radius (e.g. 10000.0) approximates a straight line.
  • All nodes of one mask need the same z coordinate.

A mask can be mirrored at a point and an axis, which is how symmetric setups with two targets are built:

m2 = rt.mirror_mask(
template_name = "Uniformity", new_name = "UniformityMirror",
mirror_point = SRT.PhysVector(-232.0, 260.0, 380.0),
mirror_axis = SRT.PhysVector(1.0, 0.0, 0.0)
)

Mirrored masks do not follow later changes of the original, and they do not inherit its trajectory.

A mask can move on its own trajectory, which is how rotating or oscillating shutters are modelled:

m.get_trajectory().generate_line(381, SRT.PhysVector(0.0, 0.0, 380.0),
SRT.PhysVector(20.0, 0.0, 380.0), 0.0)

# Pivot point of the rotation, if it is not where the mask sits on the trajectory
m.set_rotation_center(SRT.PhysVector(0.0, 1.0, 0.0))

The mask trajectory should have the same number of samples as the substrate trajectory. Check a hand-built mask for crossings of its own connections before running anything:

print("self intersections:", m.count_self_intersections())

m.dump_gmsh_geo("mask.geo", offset_points = 1000, offset_lines = 1000) writes the polygon as a GMSH geometry file for a quick look in a viewer. The offsets keep several masks from reusing the same point numbers in one file.

Running the raytracer​

Once substrate, trajectory and histogram are defined, and optionally masks, the run is a loop:

while not rt.finished():
rt.step()

rt.get_time_step() gives the current step (counting from 0) inside the loop — useful for conditionals and for filenames. The order of operations has to be kept, but anything can be put around the step, and the loop can live inside a function:

def run_scenario():
while not rt.finished():
# ... before the step
rt.step()
# ... after the step
return s.dump_list(offset = SRT.PhysVector(0.0, 0.0, 0.0), normalize_to = 1.0)

That pattern is the basis for fitting, where the same function is called once per optimisation step.

Reading the result​

The main result is the intensity on each substrate patch:

# Intensities per patch, as a list of (v0, v1, v2, v3, intensity)
values = s.dump_list(offset = SRT.PhysVector(0.0, 0.0, 0.0), normalize_to = 1.0)

# The same as a POS file for GMSH, and as CSV for everything else
s.dump_gmsh("profile.pos", offset = SRT.PhysVector(0.0, 0.0, 0.0), normalize_to = 1.0)
s.dump_csv("profile.csv", offset = SRT.PhysVector(0.0, 0.0, 0.0), normalize_to = 1.0)

Each list entry holds the four points spanning the patch and, as the last element, the intensity:

(SRT.PhysVector, SRT.PhysVector, SRT.PhysVector, SRT.PhysVector, float)
  • normalize_to = 0.0 gives absolute values, normalize_to = 1.0 scales the maximum to one.
  • use_temp_values = True returns only the last time step (a snapshot), False the accumulated sum.
  • offset and rotation_deg place the part where it sits at a given step — useful for snapshots: t.get_point_at(step) and t.get_rotation_deg_at(step) give the values to pass in.
  • s.average_temp_angular_values() and s.average_full_angular_values() average over the angular patches; the second one is permanent. Both only work if n_phi was a parameter of the geometry.
  • All three dumping routines can be called inside the loop (after the step) or after it, depending on whether you want a snapshot or the accumulated result. For one file per step, build the filename from the step number: "intensity_" + str(time_step) + ".pos".

A complete script​

Circular trajectory over a disk, one circular mask, output as a POS file. Everything above appears once, in the order it has to be called.

import SRT as SRT
import SRTHelper as SRTHelper

rt = SRT.Raytracer()
s = rt.get_substrate()
t = rt.get_trajectory()

# Substrate
s.generate_geometry("disk", {"n_r": 10, "n_phi": 10, "radius": 100.0})
if s.is_concave():
rt.precompute_substrate_intersections()
s.set_sputter_up()

# Trajectory: 11 samples on a 540 mm circle around (-232, 260, 385)
traj_radius = 540.0
t.generate_circle_arc(11, traj_radius, -19.0, 19.0, SRT.PhysVector(-232.0, 260.0, 385.0), -19.0)

# Histogram
batch = rt.add_histogram_batch("Main")
batch.add_histogram_from_file(
"histogram.txt",
SRT.PhysVector(0.0, 0.0, 100.0),
SRT.PhysVector(100.0, 100.0, 100.0),
20, 10,
0.0,
False
)

# Mask
m = rt.add_mask("Circle")
m.set_thickness(1.0)
n0 = m.add_node(SRT.PhysVector(100.0, 0.0, 100.0))
n1 = m.add_node(SRT.PhysVector(0.0, 100.0, 100.0))
n2 = m.add_node(SRT.PhysVector(-100.0, 0.0, 100.0))
n3 = m.add_node(SRT.PhysVector(0.0, -100.0, 100.0))
m.add_circle_arc(n0, n1, 100.0)
m.add_circle_arc(n1, n2, 100.0)
m.add_circle_arc(n2, n3, 100.0)
m.add_circle_arc(n3, n0, 100.0)

# Run
while not rt.finished():
rt.step()

# Output
s.dump_gmsh("intensities.pos", offset = SRT.PhysVector(0.0, 0.0, 0.0), normalize_to = 1.0)