Skip to content

Move fw surface loads to class#4095

Open
chris-ashe wants to merge 3 commits intomainfrom
move_fw_surface_loads_to_class
Open

Move fw surface loads to class#4095
chris-ashe wants to merge 3 commits intomainfrom
move_fw_surface_loads_to_class

Conversation

@chris-ashe
Copy link
Collaborator

@chris-ashe chris-ashe commented Feb 12, 2026

This pull request primarily fixes a variable naming typo (plfux_plasma_surface_neutron_avg_mwpflux_plasma_surface_neutron_avg_mw) throughout the codebase, and refactors the calculation and assignment of first wall neutron and photon power fluxes. The logic for these calculations is moved out of physics.py and consolidated within fw.py, simplifying and centralizing the power flux computations. Additionally, related output and plotting code is updated to use the corrected variable name.

Refactor and relocation of first wall power flux calculations:

  • Moved the calculation of pflux_fw_neutron_mw and pflux_fw_rad_mw from physics.py to fw.py, consolidating the logic and simplifying the code structure. The new implementation uses a more unified approach for both neutron and photon wall loads, removing configuration-specific branches from physics.py.

✅ - Within fw.py

        if physics_variables.i_pflux_fw_neutron == 1:
            physics_variables.pflux_fw_neutron_mw = (
                physics_variables.ffwal
                * physics_variables.pflux_plasma_surface_neutron_avg_mw
            )
        else:
            physics_variables.pflux_fw_neutron_mw = (
                physics_variables.p_neutron_total_mw / first_wall_variables.a_fw_total
            )

        if physics_variables.i_pflux_fw_neutron == 1:
            physics_variables.pflux_fw_rad_mw = (
                physics_variables.ffwal
                * physics_variables.p_plasma_rad_mw
                / physics_variables.a_plasma_surface
            )
        else:
            physics_variables.pflux_fw_rad_mw = (
                physics_variables.p_plasma_rad_mw / build_variables.a_fw_total
            )

        constraint_variables.pflux_fw_rad_max_mw = (
            physics_variables.pflux_fw_rad_mw * constraint_variables.f_fw_rad_max
        )

🟥 - In physics.py with redundant calculation already done by apply_first_wall_coverage_factors()

# Nominal mean neutron wall load on entire first wall area including divertor and beam holes
        # Note that 'a_fw_total' excludes these, so they have been added back in.
        if physics_variables.i_pflux_fw_neutron == 1:
            physics_variables.pflux_fw_neutron_mw = (
                physics_variables.ffwal
                * physics_variables.p_neutron_total_mw
                / physics_variables.a_plasma_surface
            )
        else:
            if divertor_variables.n_divertors == 2:
                # Double null configuration
                physics_variables.pflux_fw_neutron_mw = (
                    (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - 2.0e0 * fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.p_neutron_total_mw
                    / build_variables.a_fw_total
                )
            else:
                # Single null Configuration
                physics_variables.pflux_fw_neutron_mw = (
                    (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.p_neutron_total_mw
                    / build_variables.a_fw_total
                )

# MDK
        # Nominal mean photon wall load on entire first wall area including divertor and beam holes
        # Note that 'a_fw_total' excludes these, so they have been added back in.
        if physics_variables.i_pflux_fw_neutron == 1:
            physics_variables.pflux_fw_rad_mw = (
                physics_variables.ffwal
                * physics_variables.p_plasma_rad_mw
                / physics_variables.a_plasma_surface
            )
        else:
            if divertor_variables.n_divertors == 2:
                # Double Null configuration in - including SoL radiation
                physics_variables.pflux_fw_rad_mw = (
                    (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - 2.0e0 * fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.p_plasma_rad_mw
                    / build_variables.a_fw_total
                    + (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - 2.0e0 * fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.rad_fraction_sol
                    * physics_variables.p_plasma_separatrix_mw
                    / (build_variables.a_fw_total)
                )
            else:
                # Single null configuration - including SoL radaition
                physics_variables.pflux_fw_rad_mw = (
                    (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.p_plasma_rad_mw
                    / build_variables.a_fw_total
                    + (
                        1.0e0
                        - fwbs_variables.f_a_fw_outboard_hcd
                        - fwbs_variables.f_ster_div_single
                    )
                    * physics_variables.rad_fraction_sol
                    * physics_variables.p_plasma_separatrix_mw
                    / build_variables.a_fw_total
                )

        constraint_variables.pflux_fw_rad_max_mw = (
            physics_variables.pflux_fw_rad_mw * constraint_variables.f_fw_rad_max
        )

Variable name correction and consistency:

  • Fixed the typo in the variable name from plfux_plasma_surface_neutron_avg_mw to pflux_plasma_surface_neutron_avg_mw across all relevant files and function signatures, including initialization and output routines.

Output and plotting updates:

  • Updated output and plotting code to reference the corrected variable name, ensuring that results and visualizations use the consistent and correct identifier.

Code cleanup:

  • Removed unused imports from physics.py and updated import statements to reflect the new locations of relevant calculations.

These changes improve code clarity, maintainability, and correctness regarding the calculation and reporting of first wall neutron and photon fluxes.## Description

Checklist

I confirm that I have completed the following checks:

  • My changes follow the PROCESS style guide
  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@codecov-commenter
Copy link

codecov-commenter commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.57%. Comparing base (774b255) to head (ab1af9c).

Files with missing lines Patch % Lines
process/fw.py 0.00% 8 Missing ⚠️
process/physics.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4095   +/-   ##
=======================================
  Coverage   46.56%   46.57%           
=======================================
  Files         124      124           
  Lines       28980    28976    -4     
=======================================
  Hits        13495    13495           
+ Misses      15485    15481    -4     

☔ 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.

@chris-ashe chris-ashe marked this pull request as ready for review February 12, 2026 15:11
@chris-ashe chris-ashe requested a review from a team as a code owner February 12, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants