Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update radas to v1 #31

Merged
merged 22 commits into from
Apr 2, 2024
Merged

Update radas to v1 #31

merged 22 commits into from
Apr 2, 2024

Conversation

tbody-cfs
Copy link
Collaborator

Removes the radas submodule and replaces it with a pip-installed version.

@tbody-cfs tbody-cfs force-pushed the Update_radas_to_v1 branch from 46286c6 to b031741 Compare March 22, 2024 18:56
.github/workflows/workflow_actions.yml Outdated Show resolved Hide resolved
.github/workflows/workflow_actions.yml Outdated Show resolved Hide resolved
@tbody-cfs tbody-cfs force-pushed the Update_radas_to_v1 branch from 38948f4 to f5411a6 Compare March 22, 2024 20:57
@tbody-cfs
Copy link
Collaborator Author

from cfspopcon.read_atomic_data import AtomicData, AtomicSpecies
atomic_data = AtomicData()

from cfspopcon.atomic_data import read_atomic_data
atomic_data_2 = read_atomic_data()

for species in [
    "Helium",
    "Lithium",
    "Beryllium",
    "Carbon",
    "Nitrogen",
    "Oxygen",
    "Neon",
    "Argon",
    "Krypton",
    "Xenon",
    "Tungsten",
]:
    kind = AtomicData.CoronalLz

    dataset = atomic_data[species]

    Ne = np.logspace(np.log10(dataset.dim_electron_density.min()), np.log10(dataset.dim_electron_density.max()), num=1000, endpoint=False)
    Te = np.logspace(np.log10(dataset.dim_electron_temp.min()), np.log10(dataset.dim_electron_temp.max()), num=1000, endpoint=False)
    atomic_data.eval_interpolator(Ne, Te, kind=kind, species=species, allow_extrapolation=True).sel(dim_electron_density=1e20, method="nearest").plot(xscale="log", yscale="log", label="new")

    interpolator_2 = atomic_data_2[AtomicSpecies[species]].coronal_Lz_interpolator

    xr.DataArray(np.power(10, interpolator_2(np.log10(Te), np.log10(Ne), grid=True)), coords=dict(dim_electron_temp=Te, dim_electron_density=Ne)).sel(dim_electron_density=1e20, method="nearest").plot(xscale="log", yscale="log", label="original", linestyle="--")

    plt.title(f"{species} Lz ")
    plt.legend()

    plt.savefig(f"{species}_Lz.png")
    plt.close()

Tungsten_Z
Xenon_Z
Krypton_Z
Argon_Z
Neon_Z
Oxygen_Z
Nitrogen_Z
Carbon_Z
Beryllium_Z
Lithium_Z
Helium_Z
Tungsten_Lz
Xenon_Lz
Krypton_Lz
Argon_Lz
Neon_Lz
Oxygen_Lz
Nitrogen_Lz
Carbon_Lz
Beryllium_Lz
Lithium_Lz
Helium_Lz

@tbody-cfs tbody-cfs changed the title Draft: Update radas to v1 Update radas to v1 Apr 1, 2024
@tbody-cfs tbody-cfs requested a review from hassec April 1, 2024 19:31
@tbody-cfs
Copy link
Collaborator Author

Seems to be slower than the previous version. Why is this? Might want to try evaluate for the entire ne, Te grid at once. Alternatively, pick a single ne value (weak dependence for rates) and just use this single reference value.

@tbody-cfs
Copy link
Collaborator Author

tbody-cfs commented Apr 2, 2024

Seems to be slower than the previous version. Why is this? Might want to try evaluate for the entire ne, Te grid at once. Alternatively, pick a single ne value (weak dependence for rates) and just use this single reference value.

Fixed this in latest commit. Seems to be significantly faster to precompute as much as possible.

python -m cProfile cfspopcon/cli.py example_cases/SPARC_PRD > profile.txt

profile.txt

Copy link
Collaborator

@hassec hassec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Walked through this with @tbody-cfs in person. Comments already applied while we reviewed 🎉

LGTM 🚀

@tbody-cfs
Copy link
Collaborator Author

Checking the comparison of the Krypton data, was getting an issue where the Lz curve was going to zero at a particular temperature. Have now added logic to drop invalid rows and columns from the atomic data.

Raw data

atomic_data[AtomicSpecies.Krypton].sel(dim_electron_density=1e20, method="nearest").coronal_Lz.plot(xscale="log", yscale="log")
plt.title("Krypton")

image

New output of interpolator, dropping invalid values

Krypton_Lz

@tbody-cfs tbody-cfs merged commit 4058ba9 into main Apr 2, 2024
7 checks passed
@tbody-cfs tbody-cfs deleted the Update_radas_to_v1 branch April 2, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants