Skip to content

Commit

Permalink
More mad to bmad devel. (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSagan authored Jul 10, 2024
1 parent e8ffc38 commit d318243
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions util_programs/mad_to_bmad/mad8_to_bmad.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,13 @@ def parse_command(command, dlist):
common.var_name_list.append(dlist[0])
name = dlist[0]
value = bmad_expression(''.join(dlist[2:]), '')

for param in ele_inv_param_factor: # Converting something like "z[volt] = xxx" to "z[voltage] = xxx * 1e6"
str = '[' + param + ']'
if str not in name: continue
if param in bmad_param_name: name = name.replace(param, bmad_param_name[param])
value = add_parens(value) + ele_inv_param_factor[param]

if '[' in value or not common.prepend_vars: # Involves an element parameter
f_out.write(f'{name} = {value}\n')
else:
Expand Down
7 changes: 7 additions & 0 deletions util_programs/mad_to_bmad/madx_to_bmad.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,13 @@ def parse_command(command, dlist):
common.var_name_list.append(dlist[0])
name = dlist[0]
value = bmad_expression(command.split('=')[1].strip(), '')

for param in ele_inv_param_factor: # Converting something like "z[volt] = xxx" to "z[voltage] = xxx * 1e6"
str = '[' + param + ']'
if str not in name: continue
if param in bmad_param_name: name = name.replace(param, bmad_param_name[param])
value = add_parens(value, True) + ele_inv_param_factor[param]

if '[' in value or not common.prepend_vars: # Involves an element parameter
f_out.write(f'{name} = {value}\n')
else:
Expand Down

0 comments on commit d318243

Please sign in to comment.