Skip to content

Convert model initialisation routines to python#3586

Merged
timothy-nunn merged 34 commits intomainfrom
3433-convert-model-initialisation-routines-to-python
Apr 9, 2025
Merged

Convert model initialisation routines to python#3586
timothy-nunn merged 34 commits intomainfrom
3433-convert-model-initialisation-routines-to-python

Conversation

@timothy-nunn
Copy link
Copy Markdown
Collaborator

@timothy-nunn timothy-nunn commented Mar 12, 2025

Converts module initialisation (setting of initial defaults) to Python.

In some cases, there was not an obvious places for these functions to live and so I just added to the file that seemed to use the variables the most.

See comment below for the annoying reason there are some slight test changes despite this being a line-for-line port of the code from Fortran to Python.

@timothy-nunn timothy-nunn linked an issue Mar 12, 2025 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.54%. Comparing base (f55aca5) to head (baf8548).
⚠️ Report is 436 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3586      +/-   ##
==========================================
+ Coverage   31.01%   36.54%   +5.53%     
==========================================
  Files          87       87              
  Lines       20412    22190    +1778     
==========================================
+ Hits         6330     8110    +1780     
+ Misses      14082    14080       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timothy-nunn timothy-nunn force-pushed the 3433-convert-model-initialisation-routines-to-python branch from 95dcc3a to 1fc5a9d Compare March 20, 2025 14:57
@timothy-nunn timothy-nunn self-assigned this Mar 20, 2025
@timothy-nunn timothy-nunn force-pushed the 3433-convert-model-initialisation-routines-to-python branch 2 times, most recently from 7e17115 to 5f1352e Compare March 26, 2025 14:43
@timothy-nunn
Copy link
Copy Markdown
Collaborator Author

timothy-nunn commented Mar 26, 2025

Errors in the TF coil are being caused by setting

tfv.poisson_cond_axial = 0.3
tfv.poisson_cond_trans = 0.3

The reason
In Fortran, the variables were set like

poisson_cond_axial = 0.3
poisson_cond_trans = 0.3

If you look around, every other float variable being assigned is followed by a D0 which explicitly sets the value to double precision. Therefore, in the Fortran these variables were being initialised to single precision 0.3 (still being assigned to a double precision variable however). When we set 0.3 across the Python-Fortran interface, it does it to double precision not single precision.

To verify, I changed the Fortran code to

poisson_cond_axial = 0.3D0
poisson_cond_trans = 0.3D0

and the same errors (differences) occur as in the Python case.

@timothy-nunn timothy-nunn requested a review from jonmaddock March 28, 2025 09:02
@timothy-nunn timothy-nunn marked this pull request as ready for review March 28, 2025 09:02
Copy link
Copy Markdown
Contributor

@jonmaddock jonmaddock left a comment

Choose a reason for hiding this comment

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

Great stuff, just need to resolve conflicts then go for it!

@timothy-nunn timothy-nunn force-pushed the 3433-convert-model-initialisation-routines-to-python branch from d1c9166 to 56a2173 Compare April 8, 2025 16:41
@timothy-nunn
Copy link
Copy Markdown
Collaborator Author

A similar issue to above is occurring at:

ld_ratio_cst = 70/22

When I calculate 70/22 in Fortran and assign it to the ld_ratio_cst the large Tokamak once through test stops failing

@timothy-nunn timothy-nunn merged commit efa48fc into main Apr 9, 2025
14 of 18 checks passed
@timothy-nunn timothy-nunn deleted the 3433-convert-model-initialisation-routines-to-python branch April 9, 2025 09: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.

Convert model initialisation routines to Python

3 participants