Skip to content

Commit

Permalink
Fix #6178: analytical and simulated crystal sims
Browse files Browse the repository at this point in the history
  • Loading branch information
gurhar1133 committed Aug 2, 2023
1 parent eaa0c36 commit 2eed627
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions sirepo/package_data/template/silas/crystal.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,38 @@ def thermo_optic_sim():

if '{{ crystalSimType }}' == "analytical":
Ts = thermo.{{ pump_pulse_profile }}_solution() #solve_steady()#gaussian_solution()
nT, n0Fit, n2Fit = thermo.compute_indices(Ts)

# Positions of each evaluation point & sets of the unique values
ptzs = thermo.eval_pts[:, 2]
ptrs = (thermo.eval_pts[:, 0] ** 2 + thermo.eval_pts[:, 1] ** 2) ** 0.5
zs = unique(ptzs)
rs = unique(ptrs)
rcenter = rs.min()
zface = zs.min() if crystal.params.pop_inversion_pump_type != "right" else zs.max()

# Radial values reflected across axis & meshgrid with longitudinal values
rrs = array((-rs[::-1]).tolist() + rs[1:].tolist())
RZ, ZR = meshgrid(rrs, zs)
temp_profile = PKDict(
radial=[rs, Ts[ptzs==zface]],
longitudinal=[zs, Ts[ptrs==rcenter]]
)
pTs = Ts.reshape((len(rs), len(zs)), order='F')
pTs = array((pTs[::-1]).tolist()+pTs[1:].tolist())
heat_map = pTs.T
elif '{{ crystalSimType }}' == "simulated":
raise AssertionError("not yet implemented")
thermo.set_load('{{ pump_pulse_profile }}')
r = crystal.params.pop_inversion_pump_rep_rate
if r <= 1:
print("Using slow_solution")
Ts = thermo.slow_solution('{{ pump_pulse_profile }}')
elif r >= 100:
print("Using solve_steady")
Ts = thermo.solve_steady()
else:
raise AssertionError(f"Invalid rep rate for simulated {'{{ pump_pulse_profile }}'}")

nT, n0Fit, n2Fit = thermo.compute_indices(Ts)
# Positions of each evaluation point & sets of the unique values
ptzs = thermo.eval_pts[:, 2]
ptrs = (thermo.eval_pts[:, 0] ** 2 + thermo.eval_pts[:, 1] ** 2) ** 0.5
zs = unique(ptzs)
rs = unique(ptrs)
rcenter = rs.min()
zface = zs.min() if crystal.params.pop_inversion_pump_type != "right" else zs.max()

# Radial values reflected across axis & meshgrid with longitudinal values
rrs = array((-rs[::-1]).tolist() + rs[1:].tolist())
RZ, ZR = meshgrid(rrs, zs)
temp_profile = PKDict(
radial=[rs, Ts[ptzs==zface]],
longitudinal=[zs, Ts[ptrs==rcenter]]
)
pTs = Ts.reshape((len(rs), len(zs)), order='F')
pTs = array((pTs[::-1]).tolist()+pTs[1:].tolist())
heat_map = pTs.T
return PKDict(
thermo=thermo,
heat_map=heat_map,
Expand Down

0 comments on commit 2eed627

Please sign in to comment.