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

Add util for reading efit gfile #732

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open

Add util for reading efit gfile #732

wants to merge 46 commits into from

Conversation

f0uriest
Copy link
Member

@f0uriest f0uriest commented Oct 27, 2023

This PR creates a DESC input file from an EFIT geqdsk equilibrium file.

To dos

  • needs tests
  • check units and factors of 2pi
  • Make sure that for a non-separatrix boundary the pressure and iota profiles are truncated
  • Reorganize the code to make it more dev-friendly

Resolves #728

@f0uriest f0uriest marked this pull request as draft October 27, 2023 01:29
@github-actions
Copy link
Contributor

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.33 +/- 1.19     | -2.55e-04 +/- 2.28e-04 |  1.90e-02 +/- 1.9e-04  |  1.92e-02 +/- 1.3e-04  |
 test_build_transform_fft_midres         |     +0.26 +/- 0.83     | +2.86e-04 +/- 9.29e-04 |  1.12e-01 +/- 7.0e-04  |  1.12e-01 +/- 6.2e-04  |
 test_build_transform_fft_highres        |     +0.68 +/- 0.79     | +3.48e-03 +/- 4.04e-03 |  5.17e-01 +/- 3.2e-03  |  5.13e-01 +/- 2.5e-03  |
 test_equilibrium_init_lowres            |     -1.02 +/- 0.93     | -8.74e-03 +/- 7.91e-03 |  8.45e-01 +/- 5.1e-03  |  8.54e-01 +/- 6.0e-03  |
 test_equilibrium_init_medres            |     -0.74 +/- 0.69     | -9.47e-03 +/- 8.82e-03 |  1.26e+00 +/- 7.3e-03  |  1.27e+00 +/- 4.9e-03  |
 test_equilibrium_init_highres           |     -0.32 +/- 0.46     | -9.75e-03 +/- 1.38e-02 |  3.01e+00 +/- 8.5e-03  |  3.02e+00 +/- 1.1e-02  |
 test_objective_compile_dshape_current   |     -0.28 +/- 7.80     | -1.48e-02 +/- 4.18e-01 |  5.34e+00 +/- 3.0e-01  |  5.36e+00 +/- 2.9e-01  |
 test_objective_compile_atf              |     +1.68 +/- 5.05     | +2.67e-01 +/- 8.07e-01 |  1.62e+01 +/- 5.6e-01  |  1.60e+01 +/- 5.9e-01  |
 test_objective_compute_dshape_current   |     +1.01 +/- 4.07     | +3.40e-05 +/- 1.37e-04 |  3.39e-03 +/- 1.2e-04  |  3.36e-03 +/- 5.7e-05  |
 test_objective_compute_atf              |     -0.60 +/- 2.96     | -6.75e-05 +/- 3.34e-04 |  1.12e-02 +/- 2.4e-04  |  1.13e-02 +/- 2.3e-04  |
 test_objective_jac_dshape_current       |     -2.62 +/- 8.15     | -3.59e-03 +/- 1.12e-02 |  1.34e-01 +/- 3.3e-03  |  1.37e-01 +/- 1.1e-02  |
 test_objective_jac_atf                  |     -1.83 +/- 2.07     | -1.33e-01 +/- 1.51e-01 |  7.16e+00 +/- 1.1e-01  |  7.29e+00 +/- 1.0e-01  |
 test_perturb_1                          |     -1.43 +/- 15.69    | -1.27e-01 +/- 1.39e+00 |  8.74e+00 +/- 1.0e+00  |  8.87e+00 +/- 9.5e-01  |
 test_perturb_2                          |     -0.28 +/- 4.76     | -4.73e-02 +/- 7.96e-01 |  1.67e+01 +/- 5.9e-01  |  1.67e+01 +/- 5.3e-01  |

@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

Attention: Patch coverage is 96.83544% with 5 lines in your changes missing coverage. Please review.

Project coverage is 95.48%. Comparing base (dd3f472) to head (607618f).
Report is 13 commits behind head on master.

Files Patch % Lines
desc/efit.py 96.83% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master     #732    +/-   ##
========================================
  Coverage   95.47%   95.48%            
========================================
  Files          87       88     +1     
  Lines       22277    22435   +158     
========================================
+ Hits        21268    21421   +153     
- Misses       1009     1014     +5     
Files Coverage Δ
desc/efit.py 96.83% <96.83%> (ø)

... and 2 files with indirect coverage changes

Copy link
Contributor

github-actions bot commented Nov 9, 2023

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     -1.22 +/- 1.11     | -2.35e-04 +/- 2.14e-04 |  1.90e-02 +/- 1.4e-04  |  1.92e-02 +/- 1.6e-04  |
 test_build_transform_fft_midres         |     +0.94 +/- 0.83     | +1.06e-03 +/- 9.34e-04 |  1.14e-01 +/- 5.2e-04  |  1.13e-01 +/- 7.7e-04  |
 test_build_transform_fft_highres        |     +0.65 +/- 0.65     | +3.40e-03 +/- 3.40e-03 |  5.23e-01 +/- 3.0e-03  |  5.20e-01 +/- 1.6e-03  |
 test_equilibrium_init_lowres            |     -0.92 +/- 0.89     | -7.72e-03 +/- 7.46e-03 |  8.35e-01 +/- 4.5e-03  |  8.42e-01 +/- 6.0e-03  |
 test_equilibrium_init_medres            |     -0.42 +/- 0.78     | -5.33e-03 +/- 9.87e-03 |  1.26e+00 +/- 6.1e-03  |  1.26e+00 +/- 7.8e-03  |
 test_equilibrium_init_highres           |     +0.29 +/- 0.57     | +8.83e-03 +/- 1.71e-02 |  3.03e+00 +/- 1.1e-02  |  3.02e+00 +/- 1.3e-02  |
 test_objective_compile_dshape_current   |     -1.42 +/- 6.37     | -7.45e-02 +/- 3.33e-01 |  5.16e+00 +/- 2.4e-01  |  5.24e+00 +/- 2.3e-01  |
 test_objective_compile_atf              |     +0.69 +/- 5.80     | +1.09e-01 +/- 9.22e-01 |  1.60e+01 +/- 8.2e-01  |  1.59e+01 +/- 4.3e-01  |
 test_objective_compute_dshape_current   |     -0.70 +/- 1.14     | -2.33e-05 +/- 3.81e-05 |  3.32e-03 +/- 3.2e-05  |  3.35e-03 +/- 2.1e-05  |
 test_objective_compute_atf              |     +2.85 +/- 4.72     | +3.19e-04 +/- 5.29e-04 |  1.15e-02 +/- 5.3e-04  |  1.12e-02 +/- 4.1e-05  |
 test_objective_jac_dshape_current       |     +9.25 +/- 9.58     | +1.26e-02 +/- 1.30e-02 |  1.48e-01 +/- 8.2e-03  |  1.36e-01 +/- 1.0e-02  |
 test_objective_jac_atf                  |     -0.54 +/- 3.47     | -3.90e-02 +/- 2.52e-01 |  7.21e+00 +/- 1.2e-01  |  7.25e+00 +/- 2.2e-01  |
 test_perturb_1                          |     -1.14 +/- 10.54    | -1.22e-01 +/- 1.13e+00 |  1.06e+01 +/- 7.7e-01  |  1.07e+01 +/- 8.3e-01  |
 test_perturb_2                          |     -1.50 +/- 5.83     | -2.83e-01 +/- 1.10e+00 |  1.85e+01 +/- 6.7e-01  |  1.88e+01 +/- 8.7e-01  |

Copy link
Contributor

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +1.70 +/- 7.88     | +2.61e-04 +/- 1.21e-03 |  1.57e-02 +/- 1.2e-03  |  1.54e-02 +/- 1.5e-04  |
 test_build_transform_fft_midres         |     -0.01 +/- 1.53     | -1.11e-05 +/- 1.46e-03 |  9.58e-02 +/- 9.0e-04  |  9.58e-02 +/- 1.2e-03  |
 test_build_transform_fft_highres        |     +0.54 +/- 1.20     | +2.55e-03 +/- 5.67e-03 |  4.75e-01 +/- 3.8e-03  |  4.72e-01 +/- 4.2e-03  |
 test_equilibrium_init_lowres            |     +0.19 +/- 2.12     | +1.52e-03 +/- 1.69e-02 |  7.96e-01 +/- 1.4e-02  |  7.94e-01 +/- 8.8e-03  |
 test_equilibrium_init_medres            |     -0.10 +/- 1.19     | -1.35e-03 +/- 1.69e-02 |  1.41e+00 +/- 1.1e-02  |  1.42e+00 +/- 1.3e-02  |
 test_equilibrium_init_highres           |     -0.28 +/- 1.02     | -1.20e-02 +/- 4.29e-02 |  4.21e+00 +/- 2.9e-02  |  4.23e+00 +/- 3.2e-02  |
 test_objective_compile_dshape_current   |     +0.05 +/- 8.81     | +2.19e-03 +/- 3.64e-01 |  4.14e+00 +/- 2.5e-01  |  4.13e+00 +/- 2.7e-01  |
 test_objective_compile_atf              |     -0.28 +/- 6.19     | -2.63e-02 +/- 5.80e-01 |  9.33e+00 +/- 4.2e-01  |  9.36e+00 +/- 4.0e-01  |
 test_objective_compute_dshape_current   |     -0.45 +/- 2.10     | -9.83e-06 +/- 4.59e-05 |  2.18e-03 +/- 3.4e-05  |  2.19e-03 +/- 3.1e-05  |
 test_objective_compute_atf              |     -2.21 +/- 1.72     | -1.73e-04 +/- 1.34e-04 |  7.64e-03 +/- 9.3e-05  |  7.82e-03 +/- 9.7e-05  |
 test_objective_jac_dshape_current       |     -2.75 +/- 9.50     | -1.26e-03 +/- 4.34e-03 |  4.44e-02 +/- 3.2e-03  |  4.57e-02 +/- 2.9e-03  |
 test_objective_jac_atf                  |     -7.39 +/- 5.31     | -1.82e-01 +/- 1.30e-01 |  2.27e+00 +/- 5.0e-02  |  2.46e+00 +/- 1.2e-01  |
 test_perturb_1                          |     +1.70 +/- 13.29    | +1.46e-01 +/- 1.14e+00 |  8.73e+00 +/- 8.1e-01  |  8.59e+00 +/- 8.0e-01  |
 test_perturb_2                          |     -0.59 +/- 5.96     | -8.56e-02 +/- 8.71e-01 |  1.45e+01 +/- 7.0e-01  |  1.46e+01 +/- 5.2e-01  |

@rahulgaur104
Copy link
Collaborator

Currently, the boundary coefficients from the efit_to_desc function and the ones from SangKyeun's file do not match because his coefficients are not from the last surface. @f0uriest I think it would be better to take SangKyeun's contour extractor instead of yours.

@f0uriest
Copy link
Member Author

Currently, the boundary coefficients from the efit_to_desc function and the ones from SangKyeun's file do not match because his coefficients are not from the last surface. @f0uriest I think it would be better to take SangKyeun's contour extractor instead of yours.

I just used the LCFS that efit identifies, it's fine to change it but we should make it an option where to truncate (and also may need to modify profiles accordingly)

Copy link
Contributor

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.01 +/- 1.07     | +1.57e-06 +/- 1.66e-04 |  1.55e-02 +/- 1.4e-04  |  1.55e-02 +/- 8.5e-05  |
 test_build_transform_fft_midres         |     +0.22 +/- 1.02     | +2.13e-04 +/- 9.64e-04 |  9.51e-02 +/- 7.5e-04  |  9.49e-02 +/- 6.1e-04  |
 test_build_transform_fft_highres        |     +0.17 +/- 0.74     | +7.88e-04 +/- 3.50e-03 |  4.71e-01 +/- 2.4e-03  |  4.70e-01 +/- 2.5e-03  |
 test_equilibrium_init_lowres            |     +0.15 +/- 1.15     | +1.15e-03 +/- 9.05e-03 |  7.87e-01 +/- 7.0e-03  |  7.85e-01 +/- 5.7e-03  |
 test_equilibrium_init_medres            |     +0.37 +/- 0.94     | +5.20e-03 +/- 1.32e-02 |  1.41e+00 +/- 8.4e-03  |  1.41e+00 +/- 1.0e-02  |
 test_equilibrium_init_highres           |     -0.48 +/- 0.78     | -2.02e-02 +/- 3.28e-02 |  4.17e+00 +/- 2.4e-02  |  4.19e+00 +/- 2.3e-02  |
 test_objective_compile_dshape_current   |     -0.28 +/- 8.73     | -1.17e-02 +/- 3.57e-01 |  4.08e+00 +/- 2.7e-01  |  4.09e+00 +/- 2.4e-01  |
 test_objective_compile_atf              |     -1.08 +/- 6.52     | -9.95e-02 +/- 6.01e-01 |  9.10e+00 +/- 3.8e-01  |  9.20e+00 +/- 4.6e-01  |
 test_objective_compute_dshape_current   |     -0.12 +/- 2.15     | -2.56e-06 +/- 4.68e-05 |  2.18e-03 +/- 3.6e-05  |  2.18e-03 +/- 2.9e-05  |
 test_objective_compute_atf              |     +2.17 +/- 1.27     | +1.66e-04 +/- 9.74e-05 |  7.83e-03 +/- 5.2e-05  |  7.67e-03 +/- 8.2e-05  |
 test_objective_jac_dshape_current       |     -2.85 +/- 16.28    | -1.33e-03 +/- 7.59e-03 |  4.53e-02 +/- 3.7e-03  |  4.66e-02 +/- 6.6e-03  |
 test_objective_jac_atf                  |     -0.35 +/- 4.27     | -8.03e-03 +/- 9.78e-02 |  2.28e+00 +/- 4.9e-02  |  2.29e+00 +/- 8.4e-02  |
 test_perturb_1                          |     -0.41 +/- 13.13    | -3.45e-02 +/- 1.11e+00 |  8.42e+00 +/- 8.4e-01  |  8.46e+00 +/- 7.3e-01  |
 test_perturb_2                          |     +0.44 +/- 4.58     | +6.30e-02 +/- 6.50e-01 |  1.43e+01 +/- 4.4e-01  |  1.42e+01 +/- 4.8e-01  |

Copy link
Contributor

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +1.17 +/- 1.16     | +1.45e-04 +/- 1.43e-04 |  1.25e-02 +/- 8.3e-05  |  1.23e-02 +/- 1.2e-04  |
 test_build_transform_fft_midres         |     +2.19 +/- 1.32     | +1.98e-03 +/- 1.20e-03 |  9.25e-02 +/- 9.7e-04  |  9.05e-02 +/- 7.0e-04  |
-test_build_transform_fft_highres        |     +1.64 +/- 0.54     | +7.58e-03 +/- 2.48e-03 |  4.69e-01 +/- 1.8e-03  |  4.61e-01 +/- 1.7e-03  |
 test_equilibrium_init_lowres            |     -0.20 +/- 1.10     | -1.60e-03 +/- 8.72e-03 |  7.91e-01 +/- 6.3e-03  |  7.93e-01 +/- 6.0e-03  |
 test_equilibrium_init_medres            |     +0.94 +/- 1.08     | +1.32e-02 +/- 1.52e-02 |  1.42e+00 +/- 8.4e-03  |  1.41e+00 +/- 1.3e-02  |
 test_equilibrium_init_highres           |     +1.04 +/- 0.61     | +4.32e-02 +/- 2.53e-02 |  4.21e+00 +/- 2.1e-02  |  4.17e+00 +/- 1.4e-02  |
 test_objective_compile_dshape_current   |     +0.15 +/- 8.16     | +6.60e-03 +/- 3.57e-01 |  4.38e+00 +/- 2.5e-01  |  4.37e+00 +/- 2.5e-01  |
 test_objective_compile_atf              |     -0.26 +/- 6.99     | -2.37e-02 +/- 6.45e-01 |  9.21e+00 +/- 5.4e-01  |  9.23e+00 +/- 3.5e-01  |
 test_objective_compute_dshape_current   |     -0.55 +/- 5.80     | -1.18e-05 +/- 1.25e-04 |  2.14e-03 +/- 4.8e-05  |  2.15e-03 +/- 1.1e-04  |
 test_objective_compute_atf              |     -1.66 +/- 1.29     | -1.26e-04 +/- 9.72e-05 |  7.43e-03 +/- 6.5e-05  |  7.56e-03 +/- 7.2e-05  |
 test_objective_jac_dshape_current       |     +1.40 +/- 8.75     | +6.41e-04 +/- 4.02e-03 |  4.66e-02 +/- 3.1e-03  |  4.59e-02 +/- 2.6e-03  |
 test_objective_jac_atf                  |     +3.48 +/- 5.30     | +7.66e-02 +/- 1.17e-01 |  2.28e+00 +/- 9.5e-02  |  2.20e+00 +/- 6.7e-02  |
 test_perturb_1                          |     +0.76 +/- 13.01    | +6.54e-02 +/- 1.12e+00 |  8.65e+00 +/- 7.6e-01  |  8.58e+00 +/- 8.2e-01  |
 test_perturb_2                          |     -0.98 +/- 4.91     | -1.44e-01 +/- 7.26e-01 |  1.46e+01 +/- 5.7e-01  |  1.48e+01 +/- 4.5e-01  |

Copy link
Contributor

github-actions bot commented Jan 4, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.45 +/- 1.42     | +5.67e-05 +/- 1.77e-04 |  1.25e-02 +/- 1.2e-04  |  1.25e-02 +/- 1.3e-04  |
 test_build_transform_fft_midres         |     -0.30 +/- 1.68     | -2.81e-04 +/- 1.55e-03 |  9.20e-02 +/- 7.9e-04  |  9.23e-02 +/- 1.3e-03  |
 test_build_transform_fft_highres        |     -0.24 +/- 1.02     | -1.14e-03 +/- 4.76e-03 |  4.64e-01 +/- 3.9e-03  |  4.65e-01 +/- 2.8e-03  |
 test_equilibrium_init_lowres            |     -0.08 +/- 1.39     | -6.18e-04 +/- 1.11e-02 |  8.01e-01 +/- 8.2e-03  |  8.02e-01 +/- 7.5e-03  |
 test_equilibrium_init_medres            |     -0.41 +/- 1.41     | -5.82e-03 +/- 2.01e-02 |  1.42e+00 +/- 1.7e-02  |  1.43e+00 +/- 1.1e-02  |
 test_equilibrium_init_highres           |     +0.75 +/- 1.25     | +3.16e-02 +/- 5.22e-02 |  4.22e+00 +/- 3.7e-02  |  4.19e+00 +/- 3.7e-02  |
 test_objective_compile_dshape_current   |     -0.30 +/- 15.56    | -1.43e-02 +/- 7.35e-01 |  4.71e+00 +/- 4.3e-01  |  4.72e+00 +/- 6.0e-01  |
 test_objective_compile_atf              |     +2.85 +/- 5.23     | +2.69e-01 +/- 4.92e-01 |  9.68e+00 +/- 2.2e-01  |  9.41e+00 +/- 4.4e-01  |
 test_objective_compute_dshape_current   |     -2.72 +/- 24.29    | -6.44e-05 +/- 5.75e-04 |  2.30e-03 +/- 1.1e-04  |  2.37e-03 +/- 5.6e-04  |
 test_objective_compute_atf              |     -2.60 +/- 2.41     | -2.01e-04 +/- 1.86e-04 |  7.52e-03 +/- 1.1e-04  |  7.72e-03 +/- 1.5e-04  |
 test_objective_jac_dshape_current       |     -1.03 +/- 14.37    | -4.88e-04 +/- 6.83e-03 |  4.71e-02 +/- 4.1e-03  |  4.75e-02 +/- 5.4e-03  |
 test_objective_jac_atf                  |     +1.73 +/- 8.13     | +3.79e-02 +/- 1.78e-01 |  2.23e+00 +/- 6.9e-02  |  2.20e+00 +/- 1.6e-01  |
 test_perturb_1                          |     +3.60 +/- 15.46    | +3.08e-01 +/- 1.32e+00 |  8.87e+00 +/- 1.0e+00  |  8.57e+00 +/- 8.7e-01  |
 test_perturb_2                          |     +4.64 +/- 5.85     | +6.83e-01 +/- 8.62e-01 |  1.54e+01 +/- 5.5e-01  |  1.47e+01 +/- 6.6e-01  |

Copy link
Contributor

github-actions bot commented Jan 4, 2024

|             benchmark_name             |         dt(%)          |         dt(s)          |        t_new(s)        |        t_old(s)        | 
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
 test_build_transform_fft_lowres         |     +0.59 +/- 2.02     | +7.46e-05 +/- 2.53e-04 |  1.26e-02 +/- 1.7e-04  |  1.25e-02 +/- 1.9e-04  |
 test_build_transform_fft_midres         |     +1.38 +/- 0.95     | +1.27e-03 +/- 8.65e-04 |  9.27e-02 +/- 6.7e-04  |  9.14e-02 +/- 5.5e-04  |
 test_build_transform_fft_highres        |     +0.99 +/- 0.70     | +4.56e-03 +/- 3.21e-03 |  4.63e-01 +/- 2.0e-03  |  4.58e-01 +/- 2.5e-03  |
 test_equilibrium_init_lowres            |     -1.19 +/- 1.55     | -9.67e-03 +/- 1.26e-02 |  8.02e-01 +/- 8.8e-03  |  8.12e-01 +/- 9.0e-03  |
 test_equilibrium_init_medres            |     -1.18 +/- 1.26     | -1.70e-02 +/- 1.83e-02 |  1.43e+00 +/- 8.3e-03  |  1.45e+00 +/- 1.6e-02  |
 test_equilibrium_init_highres           |     -0.38 +/- 0.78     | -1.61e-02 +/- 3.31e-02 |  4.21e+00 +/- 2.1e-02  |  4.23e+00 +/- 2.6e-02  |
 test_objective_compile_dshape_current   |     -2.24 +/- 8.57     | -1.01e-01 +/- 3.88e-01 |  4.43e+00 +/- 2.9e-01  |  4.53e+00 +/- 2.6e-01  |
 test_objective_compile_atf              |     +0.97 +/- 6.33     | +9.14e-02 +/- 5.95e-01 |  9.49e+00 +/- 4.4e-01  |  9.39e+00 +/- 4.0e-01  |
 test_objective_compute_dshape_current   |     +0.03 +/- 2.69     | +5.71e-07 +/- 5.72e-05 |  2.13e-03 +/- 4.2e-05  |  2.13e-03 +/- 3.9e-05  |
 test_objective_compute_atf              |     -1.33 +/- 2.01     | -1.01e-04 +/- 1.53e-04 |  7.51e-03 +/- 1.3e-04  |  7.61e-03 +/- 8.6e-05  |
 test_objective_jac_dshape_current       |     -2.64 +/- 9.95     | -1.26e-03 +/- 4.75e-03 |  4.65e-02 +/- 4.5e-03  |  4.78e-02 +/- 1.6e-03  |
 test_objective_jac_atf                  |     -0.53 +/- 8.34     | -1.20e-02 +/- 1.88e-01 |  2.25e+00 +/- 1.1e-01  |  2.26e+00 +/- 1.5e-01  |
 test_perturb_1                          |     +0.10 +/- 14.48    | +8.48e-03 +/- 1.27e+00 |  8.75e+00 +/- 9.9e-01  |  8.74e+00 +/- 7.8e-01  |
 test_perturb_2                          |     +1.00 +/- 5.16     | +1.49e-01 +/- 7.66e-01 |  1.50e+01 +/- 4.3e-01  |  1.49e+01 +/- 6.4e-01  |

@dpanici dpanici requested review from dpanici and ddudt and removed request for dpanici April 3, 2024 19:41
maxiter=100,
threshold=1e-8,
):
"""Generate a DESC input file from a DESC equilibrium object.
Copy link
Collaborator

Choose a reason for hiding this comment

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

this docstring sohuld mention efit?? what is the purpose of the function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does not seem like it is related to efits at all, other than maybe the title printstring being different. You should just add to your other to_desc_input file the ability to specify the string printed at the top of the input file and whether or not the boundary is asymmetric

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right. This function is more general purpose than an input file writer for EFIT files. Right now, I don't know how to move it into another script.


DESC will automatically choose continuation parameters

Parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

some of these parameters are not actually in the init, like infile. And eq is not in the parameters but isin the init.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I have made changes to the docstring so that it is the same as the inputs to the function.

L=None,
bdry_dist=1,
):
"""Create a DESC equilibrium object from an EFIT geqdsk file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably a stupid quesiton, but in the inputs you have a eqdsk_cocos.out file, is that the same as a geqdsk file?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it's an eqdsk file. The data may have been preprocesses but the format is exactly the same as an eqdsk file.

Copy link
Collaborator

@dpanici dpanici left a comment

Choose a reason for hiding this comment

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

Instead of making a separate efit_to_desc_input fxn, use your existing function (perhaps modified so you can specify the string printed at the top of the file)

@dpanici dpanici self-requested a review May 15, 2024 19:49
Fourier coefficients below this value will be set to 0.
"""
with open(outfile, "w+") as f:
header = "# DESC input file generated from an geqdsk file\n# "
Copy link
Collaborator

Choose a reason for hiding this comment

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

would be better to allow header to be passed into this file, have the default be "generated from a DESC equilibrium on XXX date with DESC version COMMIT_TAG"

as the fxn does not need efit it should not be mentioned


with pytest.warns(UserWarning):
eq = EFITIO.load(str(efit_file_path), M=20)
ir1 = EFITIO.efit_to_desc_input(eq, tmp_path1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

change this once the method is put as a separate fxn in a separate file

Copy link
Collaborator

@dpanici dpanici left a comment

Choose a reason for hiding this comment

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

  • Move the efit_to_desc_input to a separate file (maybe somewhere in io) and also change the name to just write_desc_input as the fxn itself does not care about efit right? instead of move, just use the existing function if you have one already

iota = grid.compress(eq.compute("iota", grid=grid)["iota"])

pres_profile = PowerSeriesProfile.from_values(
rho, pressure, order=eq.L, sym=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

we probably want to enforce sym=True? since physically it should be an even function of rho? in the input file you have, the coeffs for the odd parts are super small so maybe it does not matter but things will throw warnings with sym=False

iota_profile = PowerSeriesProfile.from_values(
rho, iota, order=eq.L, sym=False
).params

Copy link
Collaborator

Choose a reason for hiding this comment

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

do we not want an option for a current profile instead of an iota profile?

@dpanici dpanici self-assigned this Aug 20, 2024
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.

Add conversion utility for EFIT geqdsk
4 participants