Shielded spectrum model (beta)
Model API name: shielded-spectrum
Shielded spectrum model (beta)
Version: v1
External Input: spectra
Input spectrum (or list of spectra) to calculate the shielded spectra from
Input | Value |
---|---|
Quantity | energy_flux_spectrum | energy_fluence_spectrum |
External Input: stopping_power
Stopping powers for all species within the input spectra
Input | Value |
---|---|
Quantity | stopping_power |
Input group: shielded-spectrum / multiplicity: one
Input | Description | Valid values | Default | Quantity |
---|---|---|---|---|
shieldThicknessUnits | Include GCR particle spectrum. |
1=mils 2=g/cm2 3=mm |
2 | number |
shieldThickness | Shield thickness |
min: 0 max: unbounded |
1 | number |
|
None
import math
import matplotlib.pyplot as plt
from nom_client.nom_client import NoMClient
plt.rcParams['figure.figsize'] = [15, 10]
plt.rc('font', size=18)
m_to_cm = 1e-4
to_omni = 4 * math.pi
mis_dur_in_days = 1
mis_dur_in_s = mis_dur_in_days * 86400
shieldThickness = 0 # g/cm2
species_name_to_plot = "H"
atomic_number_to_plot = 1
def plot(x_data, y_data, plot_types, line_types, xlabel, ylabel, labels, title):
for data_index in range(len(x_data)):
if plot_types[data_index] == 'loglog':
plt.loglog(x_data[data_index], y_data[data_index], linestyle=line_types[data_index], linewidth=2.0,
markersize=12.0,
label=labels[data_index])
elif plot_types[data_index] == 'semilogy':
plt.semilogy(x_data[data_index], y_data[data_index], linestyle=line_types[data_index], linewidth=2.0,
markersize=12.0,
label=labels[data_index])
elif plot_types[data_index] == 'semilogx':
plt.semilogx(x_data[data_index], y_data[data_index], linestyle=line_types[data_index], linewidth=2.0,
markersize=12.0,
label=labels[data_index])
else:
plt.plot(x_data[data_index], y_data[data_index], linestyle=line_types[data_index], linewidth=2.0,
markersize=12.0,
label=labels[data_index])
plt.title(title, fontsize=18)
plt.grid(True)
plt.legend(bbox_to_anchor=(0.95, 0.95), loc=1, borderaxespad=0.,
fancybox=True, fontsize=18, shadow=True)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.show()
nom_client = NoMClient(project_name="Shielded spectrum example", default_server_id="local_server", debug_output=False)
trajectory_model = nom_client.get_model('trajectory')
trajectory_model.set_params(orbitSpecificationCode="NEI", duration=mis_dur_in_days)
trajectory_result = nom_client.run_model(trajectory_model)
print(trajectory_result)
lowestIonSpecies = 1
highestIonSpecies = 92
iso_15390_model = nom_client.get_model('iso_15390')
iso_15390_model.set_params(lowestIonSpecies=lowestIonSpecies, highestIonSpecies=highestIonSpecies)
iso_15390_model.set_external_input(external_input_name="trajectory", external_input=trajectory_result)
iso_15390_results = nom_client.run_model(iso_15390_model)
print(iso_15390_results)
gcr_spectrum = iso_15390_results.get_model_result_by_name(result_name="particle_spectrum")
gcr_spectrum_energies = gcr_spectrum.get_variable_data(variable_name="energy").squeeze()
gcr_spectrum_diff_flux_m2_sr_s = gcr_spectrum.get_variable_data(variable_name="differential_flux",
species=species_name_to_plot).squeeze()
gcr_spectrum_int_flux_m2_sr_s = gcr_spectrum.get_variable_data(variable_name="integral_flux",
species=species_name_to_plot).squeeze()
gcr_spectrum_int_flux_cm2_s = gcr_spectrum_int_flux_m2_sr_s * m_to_cm * to_omni
gcr_spectrum_diff_flux_cm2_s = gcr_spectrum_diff_flux_m2_sr_s * m_to_cm * to_omni
sapphire_model = nom_client.get_model('sapphire-total-fluence')
sapphire_model.set_params(lowestIonSpecies=lowestIonSpecies, highestIonSpecies=highestIonSpecies)
sapphire_model.set_external_input(external_input_name="trajectory", external_input=trajectory_result)
sapphire_results = nom_client.run_model(sapphire_model)
print(sapphire_results)
sep_spectrum = sapphire_results.get_model_result_by_name(result_name="full_ion_spectrum")
sep_spectrum_energies = sep_spectrum.get_variable_data(variable_name="energy").squeeze()
sep_spectrum_diff_flux_cm2 = sep_spectrum.get_variable_data(variable_name="differential_fluence",
species=species_name_to_plot).squeeze()
sep_spectrum_int_flux_cm2 = sep_spectrum.get_variable_data(variable_name="integral_fluence",
species=species_name_to_plot).squeeze()
sep_spectrum_diff_flux_cm2_s = sep_spectrum_diff_flux_cm2 / mis_dur_in_s
sep_spectrum_int_flux_cm2_s = sep_spectrum_int_flux_cm2 / mis_dur_in_s
ss_model = nom_client.get_model('shielded-spectrum')
ss_model.set_params(shieldThicknessUnits=2, shieldThickness=shieldThickness)
ss_model.set_external_input(external_input_name="spectra", external_input=[gcr_spectrum, sep_spectrum])
ss_results = nom_client.run_model(ss_model)
print(ss_results)
shielded_spectrum = ss_results.get_model_result_by_name(result_name="shielded_spectrum")
calc_shielded_energy = shielded_spectrum.get_variable_data(variable_name="energy").squeeze()
calc_shielded_diff_flux = shielded_spectrum.get_variable_data(variable_name="differential_fluence",
z=atomic_number_to_plot).squeeze()
calc_shielded_int_flux = shielded_spectrum.get_variable_data(variable_name="integral_fluence",
z=atomic_number_to_plot).squeeze()
plot(x_data=[sep_spectrum_energies, gcr_spectrum_energies, calc_shielded_energy],
y_data=[sep_spectrum_diff_flux_cm2_s, gcr_spectrum_diff_flux_cm2_s*math.pi, calc_shielded_diff_flux*m_to_cm],
plot_types=["loglog", "loglog", "loglog"],
line_types=["solid", "solid", "solid"],
xlabel="Energy (MeV)",
ylabel="DIfferential flux (cm^-2 s^-1 MeV^-1)",
labels=["Unshielded SEP", "Unshielded GCR", f"Shielded ({shieldThickness} g/cm2)"],
title="")
No references