Skip to content

Comments

Various CGYRO bugfixes#512

Merged
bpatel2107 merged 11 commits intounstablefrom
bugfix/cgyro_various
Feb 17, 2026
Merged

Various CGYRO bugfixes#512
bpatel2107 merged 11 commits intounstablefrom
bugfix/cgyro_various

Conversation

@physycola
Copy link
Collaborator

This PR is intended to update PYRO to be compatible with some of the more recent CGYRO changes. Specifically, these are:

  1. A CGYRO recent commit changed the sign of the normalisation of the QL fluxes. If I am tracking the definitions of correctly in cgyro_make_profiles.F90, this means that the sign of flux_norm should be modified as shown. This gives good agreement of the QL computed before and after the change, for a case I have, but this breaks the automatic tests.

  2. CGYRO is doing away with Z_EFF and Z_EFF_METHOD as input parameters (these will give the CGYRO: bogus parameter message). The easiest way to handle these in PYRO is to remove them from set(), meaning that the user will have to specify them manually now if they want behaviour different from the current functionality of Z_EFF_METHOD=2.

Happy to take feedback @bpatel2107

@physycola physycola requested a review from bpatel2107 December 9, 2025 15:16
@bpatel2107
Copy link
Collaborator

bpatel2107 commented Dec 11, 2025

Hmm so we are getting into dangerous territory here with the code version becoming important. If we just implement the changes here as is then we break backwards compatibility with already existing CGYRO runs. CGYRO does store its git commit here so we could do some fancy stuff here with checking git commits and checking when that occurred though that could be a bit onerous.

I think removing the Z_EFF terms from the set method is a bit hacky and we should delete it in gk_input.data as that is the dictionary that is being used to write things but again we risk breaking backwards compatibility.

@ZedThree thoughts on how to proceed?

@physycola
Copy link
Collaborator Author

I agree that it's a bit annoying about the code versions. To aid decision-making, the Z_EFF change had not yet been made in the master branch of CGRYO, while the other sign change has. So we could always defer the former changes until those are integrated into master, and just fix the QL flux signs? But I guess this also still breaks backwards compatibility, so....

@ZedThree
Copy link
Collaborator

Broadly speaking, I think there are two ways of dealing with things like this: either have separate implementations for incompatible versions of a code (but that use a common base class), or have conditionals in the one implementation.

Separate implementations for different versions might add a bunch of complexity, but the benefit is that they can be named, which would allow users to explicitly do cross-version comparisons -- CODE-vX vs CODE-vX+1.

In any case, it might be difficult to deal with builds from between releases -- how do you tell if a run was down before or after a particular bug fix or change in behaviour if it's not exactly version X.Y.Z or X.Y.Z+1?

@FelixWattsYork
Copy link
Collaborator

I don't know if this is bad etiquette to add this change to the pre-exisitng PR but I thought it was less work that create a new branch and PR.
Changed default loading of CGYRO binary data to only have read permission as opposed to read and write permission (which is what np.memmap defaults to). This allows reading of CGYRO data from locations you have read access but not write access, ensures binary output data is not modified accidentally, and is consistent with how GENE data is loaded

@bpatel2107
Copy link
Collaborator

I think I'm happy enough for now so will merge and see what problems arise!


with open(filename, "w") as f:
for key, value in self.data.items():
if key in ["Z_EFF", "Z_EFF_METHOD"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should actually do something before the open like

del self.data["Z_EFF"]

@bpatel2107 bpatel2107 merged commit b65fdcb into unstable Feb 17, 2026
17 checks passed
@bpatel2107 bpatel2107 deleted the bugfix/cgyro_various branch February 17, 2026 10:39
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.

4 participants