Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
os: [ubuntu-latest]
python-version: [3.9]
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pypi_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.9
- name: Install pypa/build
run: >-
python -m
Expand Down
2 changes: 1 addition & 1 deletion pyemittance/emittance_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_emit(self):

q = np.array(self.quad_vals[dim])
# quad vals are passed in machine units
kL = kL_from_machine_value(q, self.energy)
kL = kL_from_machine_value(q, self.energy, self.quad_len)

bs = self.beam_vals[dim]
bs_err = self.beam_vals_err[dim]
Expand Down
8 changes: 4 additions & 4 deletions pyemittance/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
logger = logging.getLogger(__name__)


def kL_from_machine_value(quad_val, energy):
def kL_from_machine_value(quad_val, energy, quad_len):
"""
Calculates quadrupole strength from machine value.

Expand All @@ -33,9 +33,9 @@ def kL_from_machine_value(quad_val, energy):
gamma = energy / mec2
beta = np.sqrt(1 - 1 / gamma**2)

return c_light*quad_val * 0.1 / (beta * energy) # 1/m^2
return c_light*quad_val * quad_len / (beta * energy) # 1/m^2

def machine_value_from_kL(kL, energy):
def machine_value_from_kL(kL, energy, quad_len):
"""
Calculates machine value from quadrupole strength.

Expand All @@ -55,7 +55,7 @@ def machine_value_from_kL(kL, energy):
"""
gamma = energy / mec2
beta = np.sqrt(1 - 1 / gamma**2)
return kL * beta * energy / c_light * 10 # 1/m -> kG
return kL * beta * energy / c_light / quad_len # 1/m -> kG



Expand Down
2 changes: 1 addition & 1 deletion pyemittance/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def initial_sigma_matrix2(self, dim=''):
return sigma_from_twiss(emit, beta, alpha)

def screen_sigma(self, dim='x'):
kL = kL_from_machine_value(self.quad_value, self.energy)
kL = kL_from_machine_value(self.quad_value, self.energy, self.Lquad)
sigma0 = self.initial_sigma_matrix2(dim)
if dim == 'x':
sign = 1
Expand Down
Loading