Skip to content

Commit

Permalink
Merge branch 'improved_energy_distribution' of github.com:fusion-ener…
Browse files Browse the repository at this point in the history
…gy/openmc-plasma-source into improved_energy_distribution
  • Loading branch information
shimwell committed Mar 8, 2024
2 parents 2710cb4 + bf02573 commit 3d2f0ae
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 64 deletions.
67 changes: 35 additions & 32 deletions examples/plot_tokamak_neutron_source_density.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import matplotlib.pyplot as plt
import numpy as np
from openmc_plasma_source import tokamak_ion_temperature, tokamak_convert_a_alpha_to_R_Z, tokamak_neutron_source_density, tokamak_ion_density
from openmc_plasma_source import (
tokamak_ion_temperature,
tokamak_convert_a_alpha_to_R_Z,
tokamak_neutron_source_density,
tokamak_ion_density,
)

sample_size=20000
minor_radius=292.258
major_radius=906
mode = 'L'
ion_density_centre=45.9
sample_size = 20000
minor_radius = 292.258
major_radius = 906
mode = "L"
ion_density_centre = 45.9

# create a sample of (a, alpha) coordinates
a = np.random.random(sample_size) * minor_radius
alpha = np.random.random(sample_size) * 2 * np.pi

temperatures = tokamak_ion_temperature(
r=a,
mode=mode,
pedestal_radius=0.8 * minor_radius,
ion_temperature_pedestal=6.09,
ion_temperature_centre=ion_density_centre,
ion_temperature_beta=2,
ion_temperature_peaking_factor=8.06,
ion_temperature_separatrix=0.1,
major_radius=major_radius,
)
r=a,
mode=mode,
pedestal_radius=0.8 * minor_radius,
ion_temperature_pedestal=6.09,
ion_temperature_centre=ion_density_centre,
ion_temperature_beta=2,
ion_temperature_peaking_factor=8.06,
ion_temperature_separatrix=0.1,
major_radius=major_radius,
)

densities = tokamak_ion_density(
mode=mode,
ion_density_centre=ion_density_centre,
ion_density_peaking_factor=1,
ion_density_pedestal=1.09e20,
major_radius=major_radius,
pedestal_radius=0.8 * minor_radius,
ion_density_separatrix=3e19,
r=a,
)

neutron_source_density = tokamak_neutron_source_density(
densities, temperatures
mode=mode,
ion_density_centre=ion_density_centre,
ion_density_peaking_factor=1,
ion_density_pedestal=1.09e20,
major_radius=major_radius,
pedestal_radius=0.8 * minor_radius,
ion_density_separatrix=3e19,
r=a,
)

neutron_source_density = tokamak_neutron_source_density(densities, temperatures)

RZ = tokamak_convert_a_alpha_to_R_Z(
a=a,
alpha=alpha,
Expand All @@ -50,10 +53,10 @@
)

plt.scatter(RZ[0], RZ[1], c=neutron_source_density)
plt.gca().set_aspect('equal')
plt.gca().set_aspect("equal")
plt.xlabel("R [cm]")
plt.ylabel("Z [cm]")
plt.colorbar(label='neutron source density')
plt.colorbar(label="neutron source density")

plt.savefig('tokamak_source_neutron_source_density.png')
print('written tokamak_source_neutron_source_density.png')
plt.savefig("tokamak_source_neutron_source_density.png")
print("written tokamak_source_neutron_source_density.png")
67 changes: 35 additions & 32 deletions examples/plot_tokamak_neutron_source_strengths.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
import matplotlib.pyplot as plt
import numpy as np
from openmc_plasma_source import tokamak_ion_temperature, tokamak_convert_a_alpha_to_R_Z, tokamak_neutron_source_density, tokamak_ion_density
from openmc_plasma_source import (
tokamak_ion_temperature,
tokamak_convert_a_alpha_to_R_Z,
tokamak_neutron_source_density,
tokamak_ion_density,
)

sample_size=2000
minor_radius=292.258
major_radius=906
mode = 'L'
ion_density_centre=45.9
sample_size = 2000
minor_radius = 292.258
major_radius = 906
mode = "L"
ion_density_centre = 45.9

# create a sample of (a, alpha) coordinates
a = np.random.random(sample_size) * minor_radius
alpha = np.random.random(sample_size) * 2 * np.pi

temperatures = tokamak_ion_temperature(
r=a,
mode=mode,
pedestal_radius=0.8 * minor_radius,
ion_temperature_pedestal=6.09,
ion_temperature_centre=ion_density_centre,
ion_temperature_beta=2,
ion_temperature_peaking_factor=8.06,
ion_temperature_separatrix=0.1,
major_radius=major_radius,
)
r=a,
mode=mode,
pedestal_radius=0.8 * minor_radius,
ion_temperature_pedestal=6.09,
ion_temperature_centre=ion_density_centre,
ion_temperature_beta=2,
ion_temperature_peaking_factor=8.06,
ion_temperature_separatrix=0.1,
major_radius=major_radius,
)

densities = tokamak_ion_density(
mode=mode,
ion_density_centre=ion_density_centre,
ion_density_peaking_factor=1,
ion_density_pedestal=1.09e20,
major_radius=major_radius,
pedestal_radius=0.8 * minor_radius,
ion_density_separatrix=3e19,
r=a,
)

neutron_source_density = tokamak_neutron_source_density(
densities, temperatures
mode=mode,
ion_density_centre=ion_density_centre,
ion_density_peaking_factor=1,
ion_density_pedestal=1.09e20,
major_radius=major_radius,
pedestal_radius=0.8 * minor_radius,
ion_density_separatrix=3e19,
r=a,
)

neutron_source_density = tokamak_neutron_source_density(densities, temperatures)

strengths = neutron_source_density / sum(neutron_source_density)

RZ = tokamak_convert_a_alpha_to_R_Z(
Expand All @@ -52,10 +55,10 @@
)

plt.scatter(RZ[0], RZ[1], c=strengths)
plt.gca().set_aspect('equal')
plt.gca().set_aspect("equal")
plt.xlabel("R [cm]")
plt.ylabel("Z [cm]")
plt.colorbar(label='neutron emission strength')
plt.colorbar(label="neutron emission strength")

plt.savefig('tokamak_source_neutron_emission_strength.png')
print('written tokamak_source_neutron_emission_strength.png')
plt.savefig("tokamak_source_neutron_emission_strength.png")
print("written tokamak_source_neutron_emission_strength.png")

0 comments on commit 3d2f0ae

Please sign in to comment.