From bf025739e626edd907f96ff60d80b71bd9c5882b Mon Sep 17 00:00:00 2001 From: shimwell Date: Fri, 8 Mar 2024 10:21:10 +0000 Subject: [PATCH] [skip ci] Apply formatting changes --- .../plot_tokamak_neutron_source_density.py | 67 ++++++++++--------- .../plot_tokamak_neutron_source_strengths.py | 67 ++++++++++--------- 2 files changed, 70 insertions(+), 64 deletions(-) diff --git a/examples/plot_tokamak_neutron_source_density.py b/examples/plot_tokamak_neutron_source_density.py index 066adad..f942fec 100644 --- a/examples/plot_tokamak_neutron_source_density.py +++ b/examples/plot_tokamak_neutron_source_density.py @@ -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, @@ -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') \ No newline at end of file +plt.savefig("tokamak_source_neutron_source_density.png") +print("written tokamak_source_neutron_source_density.png") diff --git a/examples/plot_tokamak_neutron_source_strengths.py b/examples/plot_tokamak_neutron_source_strengths.py index a95802f..21671a9 100644 --- a/examples/plot_tokamak_neutron_source_strengths.py +++ b/examples/plot_tokamak_neutron_source_strengths.py @@ -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( @@ -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")