Skip to content

Commit

Permalink
fix jerome
Browse files Browse the repository at this point in the history
  • Loading branch information
jguterl committed Oct 22, 2024
1 parent e8c5c0a commit 13cc666
Show file tree
Hide file tree
Showing 16 changed files with 4,260 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CondaPkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
tikzplotlib = ""
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ year = 2024
[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Expand Down
347 changes: 347 additions & 0 deletions cooling_rates.tikz

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions examples/analysis_pedestal_sim.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#=
Author: Jerome Guterl ([email protected])
Company: General Atomics
impurity_iz_rec_timescale.jl (c) 2024=#

using ADAS, Plots
gr()
impurities = [:C, :Ne, :Si, :Ar, :Kr, :Xe, :W]
Lz = Dict(imp => ADAS.get_cooling_rates(imp) for imp in impurities);
Rrad = [ADAS.get_radiation_rates(imp) for imp in impurities];
Zeff = [ADAS.get_Zeff(imp) for imp in impurities];
Zmean = Dict(imp => ADAS.get_Zmean(imp) for imp in impurities);
Rrec = Dict(imp => ADAS.get_recombination_rate(imp) for imp in impurities);
Riz = Dict(imp => ADAS.get_ionization_rate(imp) for imp in impurities)
# Zmean = Dict(Lz_.imp => [ADAS.get_Zmean(Lz_.imp)(ne_, Te_) for (Te_, ne_) in zip(Te, ne)] for Lz_ in Lz)
using Format
using LaTeXStrings
R_ = [-18.3921, -15.1886, -12.2722, -9.6468, -7.3198, -5.2925, -3.5710, -2.164, -1.0753, -0.3050]
Prad_sim = [5.1086, 4.5802, 4.0441, 3.5318, 3.0742, 2.7724, 2.6058, 2.4659, 2.2395, 1.7829]
ne_sim = [9.1732, 8.7446, 8.3351, 7.8059, 6.9740, 6.2106, 5.5308, 4.9412, 4.4436, 4.0410] * 1e19
c_z_sim = [0.1944, 0.2034, 0.2127, 0.2271, 0.2583, 0.2992, 0.3524, 0.4204, 0.5046, 0.6109] *0.01
Te_sim = [1538.9561, 1359.4824, 1193.0386, 1038.3017, 891.58594, 750.65806, 617.58147, 496.69831, 393.1432, 312.39886]

Lz_Kr_sim = [Lz[:Kr].Lz_tot(ne_,Te_) for (ne_,Te_) in zip(ne_sim,Te_sim)]
plot(R_, Lz_Kr_sim)
plot(R_, Lz_Kr_sim .* c_z_sim .* ne_sim .^2 )



# plot(title="Average charge s
Binary file added examples/aurora_validations/line_rad_tot_Kr.npy
Binary file not shown.
58 changes: 58 additions & 0 deletions examples/aurora_validations/plot_cooling_rates.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

using ADAS, Plots, OrderedCollections, Format
gr()

using PyCall
aurora = pyimport("aurora")
np =pyimport("numpy")
Te_eV = np.logspace(np.log10(1), np.log10(1e4), 1000)
ne_cm3 = 10e13 * np.ones_like(Te_eV)
imp = "Kr"
line_rad_tot, cont_rad_tot = aurora.get_cooling_factors(imp, ne_cm3, Te_eV, plot=true, ion_resolved=false)
files = ["scd", "acd"]
atom_data_eq = aurora.get_atom_data(imp, files)
_Te, fz = aurora.get_frac_abundances(atom_data_eq, ne_cm3, Te_eV)
#=
import aurora
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
# scan Te and fix a value of ne
Te_eV = np.logspace(np.log10(1), np.log10(1e4), 1000)
ne_cm3 = 10e13 * np.ones_like(Te_eV)
imp = "Kr"
# basic cooling curve, considering ionization equilibrium between charge states
line_rad_tot, cont_rad_tot = aurora.get_cooling_factors(
imp, ne_cm3, Te_eV, plot=True, ion_resolved=False
)
aurora.get_frac_abundances(imp, ne_cm3, Te_eV, plot=True)
files = ["scd", "acd"]
atom_data_eq = aurora.get_atom_data(imp, files)
_Te, fz = aurora.get_frac_abundances(atom_data_eq, ne_cm3, Te_eV)
=#
impurities = [:Kr]
color_ = [:orange, :gray, :blue, :black, :cyan, :red]

Lz = OrderedDict(imp => ADAS.get_cooling_rates(imp; plt_year="41") for imp in impurities);
using Plots
Log10Range(args...; kw...) = 10 .^ LinRange(args...; kw...)
p = plot(layout=1, framestyle=:box, palette=:darktest, size=(400, 400))
for (i, Lz_) in enumerate(values(Lz))
plot!(Lz_, Te=Log10Range(0, 4, 1000), xlim=[5.0, 2e4], ylim=[1e-34, 5e-31], xscale=:log10, yscale=:log10, layout=1, color=color_[i])
end
plot!(Te_aurora, Lz_aurora, label="aurora Kr")
plot!()
y = Log10Range(-34, -31, 4)
x = Log10Range(1, 4, 4)
yticks!(p, y)
xticks!(p, x)
plot!(legendposition=:bottomright, legendfontsize=12, legendcolumns=2)
223 changes: 223 additions & 0 deletions examples/cr_vapor_pressure.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# from https://www2.iap.tuwien.ac.at/www/surface/vapor_pressure
# T(K) T(°C) p(bar)
300.0 26.85 0
310.0 36.85 2.47e-57
320.0 46.85 2.38e-55
330.0 56.85 1.74e-53
340.0 66.85 9.87e-52
350.0 76.85 4.45e-50
360.0 86.85 1.62e-48
370.0 96.85 4.88e-47
380.0 106.9 1.23e-45
390.0 116.9 2.61e-44
400.0 126.9 4.77e-43
410.0 136.9 7.57e-42
420.0 146.9 1.05e-40
430.0 156.9 1.29e-39
440.0 166.9 1.42e-38
450.0 176.9 1.40e-37
460.0 186.9 1.25e-36
470.0 196.9 1.02e-35
480.0 206.9 7.59e-35
490.0 216.9 5.21e-34
500.0 226.9 3.32e-33
510.0 236.9 1.96e-32
520.0 246.9 1.08e-31
530.0 256.9 5.61e-31
540.0 266.9 2.73e-30
550.0 276.9 1.26e-29
560.0 286.9 5.48e-29
570.0 296.9 2.27e-28
580.0 306.9 8.93e-28
590.0 316.9 3.36e-27
600.0 326.9 1.21e-26
610.0 336.9 4.17e-26
620.0 346.9 1.38e-25
630.0 356.9 4.41e-25
640.0 366.9 1.36e-24
650.0 376.9 4.03e-24
660.0 386.9 1.16e-23
670.0 396.9 3.23e-23
680.0 406.9 8.74e-23
690.0 416.9 2.30e-22
700.0 426.9 5.87e-22
710.0 436.9 1.46e-21
720.0 446.9 3.55e-21
730.0 456.9 8.40e-21
740.0 466.9 1.94e-20
750.0 476.9 4.40e-20
760.0 486.9 9.74e-20
770.0 496.9 2.11e-19
780.0 506.9 4.49e-19
790.0 516.9 9.38e-19
800.0 526.9 1.92e-18
810.0 536.9 3.87e-18
820.0 546.9 7.65e-18
830.0 556.9 1.49e-17
840.0 566.9 2.85e-17
850.0 576.9 5.38e-17
860.0 586.9 1.00e-16
870.0 596.9 1.83e-16
880.0 606.9 3.31e-16
890.0 616.9 5.91e-16
900.0 626.9 1.04e-15
910.0 636.9 1.81e-15
920.0 646.9 3.11e-15
930.0 656.9 5.28e-15
940.0 666.9 8.88e-15
950.0 676.9 1.47e-14
960.0 686.9 2.42e-14
970.0 696.9 3.94e-14
980.0 706.9 6.35e-14
990.0 716.9 1.01e-13
1000 726.9 1.60e-13
1010 736.9 2.51e-13
1020 746.9 3.90e-13
1030 756.9 6.00e-13
1040 766.9 9.16e-13
1050 776.9 1.39e-12
1060 786.9 2.08e-12
1070 796.9 3.11e-12
1080 806.9 4.60e-12
1090 816.9 6.76e-12
1100 826.9 9.86e-12
1110 836.9 1.43e-11
1120 846.9 2.06e-11
1130 856.9 2.95e-11
1140 866.9 4.19e-11
1150 876.9 5.92e-11
1160 886.9 8.31e-11
1170 896.9 1.16e-10
1180 906.9 1.61e-10
1190 916.9 2.23e-10
1200 926.9 3.06e-10
1210 936.9 4.18e-10
1220 946.9 5.68e-10
1230 956.9 7.68e-10
1240 966.9 1.03e-9
1250 976.9 1.38e-9
1260 986.9 1.85e-9
1270 996.9 2.45e-9
1280 1007 3.24e-9
1290 1017 4.26e-9
1300 1027 5.59e-9
1310 1037 7.29e-9
1320 1047 9.47e-9
1330 1057 1.23e-8
1340 1067 1.58e-8
1350 1077 2.03e-8
1360 1087 2.60e-8
1370 1097 3.32e-8
1380 1107 4.22e-8
1390 1117 5.34e-8
1400 1127 6.74e-8
1410 1137 8.48e-8
1420 1147 1.06e-7
1430 1157 1.33e-7
1440 1167 1.66e-7
1450 1177 2.06e-7
1460 1187 2.55e-7
1470 1197 3.15e-7
1480 1207 3.88e-7
1490 1217 4.76e-7
1500 1227 5.83e-7
1510 1237 7.13e-7
1520 1247 8.68e-7
1530 1257 1.05e-6
1540 1267 1.28e-6
1550 1277 1.55e-6
1560 1287 1.86e-6
1570 1297 2.24e-6
1580 1307 2.69e-6
1590 1317 3.23e-6
1600 1327 3.86e-6
1610 1337 4.60e-6
1620 1347 5.47e-6
1630 1357 6.49e-6
1640 1367 7.69e-6
1650 1377 9.10e-6
1660 1387 1.07e-5
1670 1397 1.26e-5
1680 1407 1.49e-5
1690 1417 1.74e-5
1700 1427 2.04e-5
1710 1437 2.39e-5
1720 1447 2.78e-5
1730 1457 3.24e-5
1740 1467 3.77e-5
1750 1477 4.37e-5
1760 1487 5.06e-5
1770 1497 5.86e-5
1780 1507 6.76e-5
1790 1517 7.80e-5
1800 1527 8.98e-5
1810 1537 1.03e-4
1820 1547 1.18e-4
1830 1557 1.36e-4
1840 1567 1.55e-4
1850 1577 1.77e-4
1860 1587 2.02e-4
1870 1597 2.30e-4
1880 1607 2.62e-4
1890 1617 2.98e-4
1900 1627 3.38e-4
1910 1637 3.83e-4
1920 1647 4.33e-4
1930 1657 4.89e-4
1940 1667 5.52e-4
1950 1677 6.23e-4
1960 1687 7.01e-4
1970 1697 7.88e-4
1980 1707 8.85e-4
1990 1717 9.93e-4
2000 1727 1.11e-3
2010 1737 1.25e-3
2020 1747 1.39e-3
2030 1757 1.56e-3
2040 1767 1.74e-3
2050 1777 1.93e-3
2060 1787 2.15e-3
2070 1797 2.40e-3
2080 1807 2.66e-3
2090 1817 2.95e-3
2100 1827 3.28e-3
2110 1837 3.63e-3
2120 1847 4.02e-3
2130 1857 4.42e-3
2140 1867 4.84e-3
2150 1877 5.30e-3
2160 1887 5.80e-3
2170 1897 6.34e-3
2180 1907 6.93e-3
2190 1917 7.57e-3
2200 1927 8.25e-3
2210 1937 9.00e-3
2220 1947 9.80e-3
2230 1957 0.0107
2240 1967 0.0116
2250 1977 0.0126
2260 1987 0.0137
2270 1997 0.0148
2280 2007 0.0161
2290 2017 0.0174
2300 2027 0.0189
2310 2037 0.0204
2320 2047 0.0221
2330 2057 0.0239
2340 2067 0.0258
2350 2077 0.0278
2360 2087 0.0300
2370 2097 0.0323
2380 2107 0.0348
2390 2117 0.0375
2400 2127 0.0403
2410 2137 0.0434
2420 2147 0.0466
2430 2157 0.0500
2440 2167 0.0537
2450 2177 0.0576
2460 2187 0.0618
2470 2197 0.0662
2480 2207 0.0708
2490 2217 0.0758
2500 2227 0.0811
2,797 changes: 2,797 additions & 0 deletions examples/pedestal_radiation_solps.ipynb

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions examples/plot_Zeff_export_tex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

using ADAS, Plots, OrderedCollections, Format, PGFPlotsX

impurities = [:Ne, :Ar, :Cr, :Kr, :W]
color_ = [:blue, :green, :red, :black, :cyan, :red]
Lz = OrderedDict(imp => ADAS.get_cooling_rates(imp) for imp in impurities);
Zeff = Dict(imp => ADAS.get_Zeff(imp) for imp in impurities)
pgfplotsx()
Log10Range(args...; kw...) = 10 .^ LinRange(args...; kw...)
p = plot(layout=1, framestyle=:box, palette=:darktest, size=(400, 400))
for (i, Lz_) in enumerate(values(Lz))
plot!(Lz_, Te=Log10Range(0.5, 4.5, 1000), xlim=[5.0, 2e4], ylim=[1e-34, 5e-31], xscale=:log10, yscale=:log10, layout=1, color=color_[i])
end
# y = Log10Range(-34, -31, 4)
# x = Log10Range(1, 4, 4)
# yticks!(p, y)
# xticks!(p, x)
# plot!(legendposition=:bottomright, legendfontsize=12, legendcolumns=2)
# #%%
# using NumericalIntegration
# Prad_tot = Dict(k => NumericalIntegration.integrate(r_omp, v) for (k, v) in Pvol_rad)
# fraction_imp = 0.0:0.001:0.005
# Zeff_ped = Dict(imp => [ADAS.get_Zeff(imp)(f, ne_ped, Te_ped) for f in fraction_imp] for imp in impurities)
using LaTeXStrings
p = plot()
Te = Log10Range(1, 4, 100)
ne = 1e19
fraction = [0.001, 0.01]
color_ = [:blue, :green, :red, :black, :cyan, :red]
linestyle_ = [:solid,:dash]
plot!(xlabel="Te[eV]", ylabel=L"$Z_{eff} = \frac{\sum n_a Z_a^2}{n_e}")
plot!(title="Zeff in C-R equilibrium\n", titlefontsize=8)
for (i,imp) in enumerate([:Ne,:Ar,:Kr])
for (j,f) in enumerate(fraction)
plot!(Te, [Zeff[imp](f, ne, Te_) for Te_ in Te], label="$imp : $(f*100)%", lw=1.0, color=color_[i],linestyle=linestyle_[j])
end
end
fs =12
plot!(framestyle=:box, ylims=(0, 5.0), xtickfontsize=fs, ytickfontsize=fs, xguidefontsize=fs, yguidefontsize=fs, legendfontsize=fs)
#save("zeff.tikz", p)
Loading

0 comments on commit 13cc666

Please sign in to comment.