Skip to content

Conversation

Copy link

Copilot AI commented Dec 25, 2025

Fortran VMEC wout files contain an lrfp__logical__ flag that was missing from VMEC++ output, requiring special handling. This adds the flag with default value false to enable reading and writing Fortran wout files without special handling.

Changes

Python layer only:

  • Added lrfp field to VmecWOut model (output only, not input)
  • Implemented Pydantic annotations: PlainSerializer (bool→int), BeforeValidator (int→bool), alias lrfp__logical__
  • Added lrfp__logical__() property accessor for NetCDF compatibility

Backwards compatibility:

  • from_wout_file() uses setdefault("lrfp__logical__", 0) to handle old wout files
  • Removed from _MISSING_FORTRAN_VARIABLES test list

No C++ implementation:

  • The flag is handled entirely on the Python side for wout file I/O
  • Not exposed in VmecInput since there's no C++ backend support
# Old wout files load with default
wout = vmecpp.VmecWOut.from_wout_file("old_wout.nc")
assert wout.lrfp is False  # defaults to False

# New wout files include the flag
wout.save("new_wout.nc")
# NetCDF file contains lrfp__logical__ = 0

Note: Flag is available for compatibility; RFP-specific physics not yet implemented.

Original prompt

add the lrfp_logical_ with default to false to the wout, to allow them to avoid having to treat VMEC++ files in any special way. Use the same pattern for adding a boolean flag as for the other flags (accessible as lrfp property from python, but written to netcdf with the logical suffix) and make sure wout files WITHOUT the flags, stay backwards compatible.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@jurasic-pf
Copy link
Collaborator

to address incompatibilities discussed in PlasmaControl/DESC#2014

Copilot AI and others added 3 commits December 25, 2025 09:57
Co-authored-by: jurasic-pf <166746189+jurasic-pf@users.noreply.github.com>
Co-authored-by: jurasic-pf <166746189+jurasic-pf@users.noreply.github.com>
Co-authored-by: jurasic-pf <166746189+jurasic-pf@users.noreply.github.com>
Copilot AI changed the title [WIP] Add lrfp_logical flag with default to false in wout files Add lrfp_logical_ flag to wout for Fortran VMEC compatibility Dec 25, 2025
Copilot AI requested a review from jurasic-pf December 25, 2025 10:02
@jurasic-pf
Copy link
Collaborator

@copilot Don't add it to the C++ source, it should only be handled on the python side and ignored.

Co-authored-by: jurasic-pf <166746189+jurasic-pf@users.noreply.github.com>
Copy link
Author

Copilot AI commented Dec 25, 2025

@copilot Don't add it to the C++ source, it should only be handled on the python side and ignored.

Removed all C++ implementation in commit f82f946. The lrfp flag is now only handled on the Python side in VmecWOut for reading/writing Fortran wout files, with backwards compatibility for old files. Also removed the test as requested.

Copilot AI changed the title Add lrfp_logical_ flag to wout for Fortran VMEC compatibility Add lrfp_logical_ flag to wout for Fortran VMEC compatibility (Python-only) Dec 25, 2025
@jurasic-pf jurasic-pf marked this pull request as ready for review December 25, 2025 12:04
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