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

WIP: Add new EQDSK based on ITER hybrid scenario CHEASE data #482

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

WIP: Add new EQDSK based on ITER hybrid scenario CHEASE data

@jcitrin
Copy link
Collaborator

jcitrin commented Oct 31, 2024

@theo-brown , @fusionby2030

First look has exposed a number of issues:

  1. For the eqdsk library to even ingest the file, need the suffix .eqdsk and to remove the footer of CHEASE-added info (useful info, but the eqdsk library is unhappy with it). That's done here

  2. In geometry.py

    # TODO(b/375696414) explore replacing with a more robust method
    epsilon = constants.CONSTANTS.eps  # 1e-7

    psi_interpolant = np.linspace(
        eqfile['psimag'] + epsilon, eqfile['psibdry'] - epsilon, 100
    )

    surfaces = []
    cg_psi = contourpy.contour_generator(X, Z, masked_psi_eqdsk_2dgrid)

    for _, _psi in enumerate(psi_interpolant):
      vertices = cg_psi.create_contour(_psi)
      x_surface, z_surface = vertices[0].T[0], vertices[0].T[1]
      surfaces.append((x_surface, z_surface))

Indeed this TODO is important. For this EQDSK, epsilon=1e-7 is too small and no vertices are found (vertices is empty) for the first iteration of for loop, and vertices[0] crashes. I think it may be better to special-case the first "surface" on the magnetic axis with the expected geometry Intermediates for the magnetic axis, and then start the iteration at a position clearly not on-axis.

I can also imagine there being issues with vertices if the number of surfaces requested is much higher than what the eqdsk file resolution can support. Therefore, perhaps the number of surfaces can be a geometry config input option, and can even imagine something fancy like trying to find the vertices of the first non-axis point and if it values, to reduce iteratively the number of requested surfaces until success (and output a user warning).

By hacking epsilon, got this to work. Unfortunately geometry outputs looked weird, i.e. volumes and areas much less than expected for ITER. Probably not a big deal but haven't looked deeper due to lack of time. Will pick this up again later. If someone else would like a crack in the meantime please go ahead, and can push to this PR.

@theo-brown
Copy link
Collaborator

For the eqdsk library to even ingest the file, need the suffix .eqdsk and to remove the footer of CHEASE-added info (useful info, but the eqdsk library is unhappy with it). That's done here

IMO this is ok, as it's on the user to provide a valid EQDSK file. Were you flagging this as a problem or as a general thing to note?

@theo-brown
Copy link
Collaborator

For this EQDSK, epsilon=1e-7 is too small and no vertices are found (vertices is empty) for the first iteration of for loop, and vertices[0] crashes

Unfortunately geometry outputs looked weird, i.e. volumes and areas much less than expected for ITER.

Yes, got the same error (regarding vertices[0]) and slightly odd geometry outputs on a STEP EQDSK file.

@jcitrin
Copy link
Collaborator

jcitrin commented Oct 31, 2024

IMO this is ok, as it's on the user to provide a valid EQDSK file. Were you flagging this as a problem or as a general thing to note?

I agree. It was just to note.

@jcitrin
Copy link
Collaborator

jcitrin commented Oct 31, 2024

Another small thing I noticed that should be fixed is that Rmaj for the geometry Intermediates is taken as the axis R, as opposed to the geometric R.

@fusionby2030
Copy link
Contributor

I have a pile of TSVV and WPTE tasks to finish before end of year, so it is unclear how quickly I can help out here.

Although, I am interested in this, and will look into generating equilibria from CHEASE and HELENA (both output EQDSK as well) for a size & current scan to investigate the systematic differences. Targeting JET/ASDEX/TCV.

But other commitments mean I can't promise anything quickly on my side.

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.

3 participants