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

Convert model initialisation routines to python #3586

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

timothy-nunn
Copy link
Contributor

@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

codecov-commenter commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.38%. Comparing base (03a8c56) to head (d1c9166).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3586      +/-   ##
==========================================
+ Coverage   31.76%   37.38%   +5.62%     
==========================================
  Files          85       85              
  Lines       20175    21983    +1808     
==========================================
+ Hits         6408     8218    +1810     
+ Misses      13767    13765       -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 from 1fc5a9d to c4770f3 Compare March 20, 2025 15:39
@timothy-nunn timothy-nunn force-pushed the 3433-convert-model-initialisation-routines-to-python branch from 7e17115 to 5f1352e Compare March 26, 2025 14:43
@timothy-nunn
Copy link
Contributor 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
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
2 participants