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

Utility for writing to IMAS #15

Open
eldond opened this issue Jul 30, 2024 · 7 comments · May be fixed by #16
Open

Utility for writing to IMAS #15

eldond opened this issue Jul 30, 2024 · 7 comments · May be fixed by #16
Assignees

Comments

@eldond
Copy link
Collaborator

eldond commented Jul 30, 2024

Hi,
I have https://github.com/ProjectTorreyPines/SD4SOLPS.jl/blob/24af0ba75505bc56ce9a57b122c8cd9fcc721383/src/SD4SOLPS.jl#L78 which uses EFIT.jl output and translates data into the IMAS schema. I developed this within one of the repos from our project, but maybe it makes more sense as part of EFIT.jl? IMASDD is already a dependency. Let me know if I should move this function. Maybe it would go in io.jl?

@orso82
Copy link
Contributor

orso82 commented Jul 30, 2024

@eldond I would avoid adding derived quantities to dd, since that's something that the IMAS.jl package will be able to do directly from the data in dd. Also, be careful to always load data in COCOS 11 when it goes into dd. gEQDSKs can have 4 different COCOS conventions: https://docs.google.com/document/d/1-efimTbI55SjxL_yE_GKSmV4GEvdzai7mAj5UYLLUXw/edit

Perhaps this would be a better starting point:

https://github.com/ProjectTorreyPines/FUSE.jl/blob/955016241ca32a17b471f2a604ae90e4ca1c1b9f/src/actors/equilibrium/chease_actor.jl#L158

"""
    gEQDSK2IMAS(GEQDSKFile::GEQDSKFile,eq::IMAS.equilibrium)

Convert IMAS.equilibrium__time_slice to MXHEquilibrium.jl EFIT structure
"""
function gEQDSK2IMAS(g::CHEASE.EFIT.GEQDSKFile, eq::IMAS.equilibrium)
    tc = CoordinateConventions.transform_cocos(1, 11) # chease output is cocos 1 , dd is cocos 11

    eqt = eq.time_slice[]
    eq1d = eqt.profiles_1d
    eq2d = resize!(eqt.profiles_2d, 1)[1]

    @ddtime(eq.vacuum_toroidal_field.b0 = g.bcentr)
    eq.vacuum_toroidal_field.r0 = g.rcentr

    eqt.global_quantities.magnetic_axis.r = g.rmaxis
    eqt.boundary.geometric_axis.r = g.rcentr
    eqt.boundary.geometric_axis.z = g.zmid
    eqt.global_quantities.magnetic_axis.z = g.zmaxis
    eqt.global_quantities.ip = g.current

    eq1d.psi = g.psi .* tc["PSI"]
    eq1d.q = g.qpsi
    eq1d.pressure = g.pres
    eq1d.dpressure_dpsi = g.pprime .* tc["PPRIME"]
    eq1d.f = g.fpol .* tc["F"]
    eq1d.f_df_dpsi = g.ffprim .* tc["F_FPRIME"]

    eq2d.grid_type.index = 1
    eq2d.grid.dim1 = g.r
    eq2d.grid.dim2 = g.z
    eq2d.psi = g.psirz .* tc["PSI"]

    return nothing
end

@eldond
Copy link
Collaborator Author

eldond commented Jul 30, 2024

Okay. Should the writing function be in EFIT or in IMAS, though?

@orso82
Copy link
Contributor

orso82 commented Jul 30, 2024

Whether you mean efit2imas or imas2efit I think those should exist in the EFIT.jl package

@eldond
Copy link
Collaborator Author

eldond commented Jul 30, 2024

This stops us from importing EFIT into IMAS later because it would create a circular dependency, right?

@orso82
Copy link
Contributor

orso82 commented Jul 31, 2024

@eldond we do not need nor want to import EFIT into IMAS. Is there some specific use case that you have in mind?

@eldond
Copy link
Collaborator Author

eldond commented Jul 31, 2024

@orso82 I want to import data from an eqdsk file into IMAS. I am using EFIT.jl to do this so far.

@orso82
Copy link
Contributor

orso82 commented Jul 31, 2024

EFIT.jl with IMASdd.jl as a dependency, and efit2imas and imas2efit functions will be able to do that. No circular dependency needed.

@eldond eldond linked a pull request Aug 2, 2024 that will close this issue
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 a pull request may close this issue.

5 participants