Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use traceon_pro solver in 3d examples #179

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion examples/deflector-3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
import numpy as np

import traceon.geometry as G
import traceon.solver as S
import traceon.excitation as E
import traceon.plotting as P
import traceon.tracing as T

try:
import traceon_pro.solver as S
except ImportError:
S = None

# Dimensions used for the deflector.
THICKNESS = 0.5
SPACING = 0.5
Expand Down Expand Up @@ -67,6 +71,9 @@ def rectangle_electrode(x, z, name):

# Use the Boundary Element Method (BEM) to calculate the surface charges,
# the surface charges gives rise to a electrostatic field.
assert S is not None, ("The 'traceon_pro' package is not installed or not found. "
"Traceon Pro is required to solve 3D geometries.\n"
"For more information, visit: https://www.traceon.org")
field = S.solve_direct(excitation)

# An instance of the tracer class allows us to easily find the trajectories of
Expand Down
9 changes: 7 additions & 2 deletions examples/dohi-mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import traceon.geometry as G
import traceon.excitation as E
import traceon.tracing as T
import traceon.solver as S
import traceon.plotting as P
import traceon.focus as F
from traceon.field import FieldRadialAxial


try:
import traceon_pro.solver as S
except ImportError:
S = None

PLOTTING = False
MSF = 20
Expand Down Expand Up @@ -78,6 +80,9 @@
excitation.add_electrostatic_boundary('boundary')
# Use the Boundary Element Method (BEM) to calculate the surface charges,
# the surface charges gives rise to a electrostatic field.
assert S is not None, ("The 'traceon_pro' package is not installed or not found. "
"Traceon Pro is required to solve 3D geometries.\n"
"For more information, visit: https://www.traceon.org")
field = S.solve_direct(excitation)

tracer = field.get_tracer( [(-r/2, r/2), (-r/2, r/2), (-7, 15.1)] )
Expand Down
13 changes: 10 additions & 3 deletions examples/stigmator.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Simulation of a stimgator using the boundary sweeping functions introduced in v0.8.0.
# Shows how particles of general mass and charge can be traced since v0.8.0

import numpy as np
import matplotlib.pyplot as plt
from scipy.constants import m_p, e

import traceon.geometry as G
import traceon.solver as S
import traceon.excitation as E
import traceon.plotting as P
import traceon.tracing as T

try:
import traceon_pro.solver as S
except ImportError:
S = None


# Multipole configuration
ORDER = 2 # A second-order multipole (quadrupole) acts a stigmator
THICKNESS = 0.1
Expand Down Expand Up @@ -56,6 +60,9 @@
excitation.add_voltage(positive_electrode=1, negative_electrode=-1, boundary=0)

# Calculate field
assert S is not None, ("The 'traceon_pro' package is not installed or not found. "
"Traceon Pro is required to solve 3D geometries.\n"
"For more information, visit: https://www.traceon.org")
field = S.solve_direct(excitation)

# Plot mesh and equipotential lines
Expand Down Expand Up @@ -89,7 +96,7 @@
start_point = np.array([x, y, z_start])

_, e_trace = tracer(start_point, e_start_velocity) # electrons are default
_, p_trace = tracer(start_point, a_start_velocity, mass=4*m_p, charge=2*e) # alpha-oarticle = two protons + two neutrons
_, p_trace = tracer(start_point, a_start_velocity, mass=4*m_p, charge=2*e) # alpha-particle = two protons + two neutrons

e_trajectories.append(e_trace)
a_trajectories.append(p_trace)
Expand Down
Loading