Repository navigation
Feature/veqpy - #4597
Closed
chencx04 wants to merge 61 commits into
Closed
Feature/veqpy#4597chencx04 wants to merge 61 commits into
chencx04 wants to merge 61 commits into
Conversation
This commit introduces a comprehensive markdown file outlining the main usage scenarios of the PROCESS system, including CLI and Python API entry points, optimization, evaluation, and parameter scanning methods. It details the core calling chain, key classes involved, and provides flowcharts for better understanding. This documentation aims to enhance user guidance and clarify the operational structure of PROCESS.
…a geometry This commit introduces a new plasma geometry option (`i_plasma_geometry = 13`) that allows users to specify the last closed flux surface using discrete (R, Z) points. It includes the addition of `r_array` and `z_array` inputs, which are validated and processed to derive key plasma parameters such as `rmajor`, `rminor`, `kappa`, and `triang`. The implementation also tracks the number of LCFS points provided and updates relevant documentation to reflect these changes.
This commit introduces new variables and logic to handle proton-boron fusion reactions in the physics model. It adds the necessary input variables for boron-11 and proton fuel fractions, updates the physics calculations to account for these new fuel types, and includes the boron atom mass constant. Additionally, it modifies the impurity radiation model to incorporate boron as a new impurity species. Relevant tests have been updated to reflect these changes.
…alculations This commit introduces a user-defined plasma current option (`i_plasma_current = 0`) that allows users to specify the plasma current directly via `plasma_current_user_input`. It updates the relevant physics models to handle this new input, including validation checks to ensure positive values. Additionally, a new `PlasmaEquilibrium` model is added to facilitate equilibrium calculations, integrating it into the existing physics framework. Documentation is updated to reflect these changes, enhancing user guidance on plasma current configurations.
This commit adds validation logic to ensure that when plasma equilibrium is solved (`i_equilibrium_solve=1`), the plasma current and current profile index must be user-specified. It raises appropriate errors if these conditions are not met. Additionally, it updates the physics model to calculate the total magnetic field and its components, ensuring consistency in the plasma equilibrium calculations. This enhances the robustness of the plasma modeling framework.
This commit introduces a new static method `bootstrap_fraction_sauter_equilibrium` in the `PlasmaBootstrapCurrent` class to calculate the bootstrap fraction based on Sauter equilibrium conditions. Additionally, a new static method `diamagnetic_integral` is added to the `PlasmaDiamagneticCurrent` class for calculating the diamagnetic integral based on the plasma equilibrium. These enhancements improve the accuracy and functionality of the plasma current models, facilitating more detailed plasma behavior analysis.
This commit refactors the import statements in the plasma model files to ensure consistency and clarity. It also adds detailed docstrings to several methods, including error handling for invalid inputs in the plasma geometry and equilibrium classes. Additionally, it improves the readability of the plasma current calculations by restructuring conditional checks. These changes enhance the maintainability of the code and provide better guidance for future developers.
This commit introduces a new `VeqpyRuntime` class to manage the latest veqpy equilibrium state and its associated axis iteration results. It also refactors the plasma equilibrium handling in the `PlasmaEquilibrium` class, adding methods to store and clear veqpy equilibrium data. The code now checks for the availability of veqpy equilibrium results in various plasma profile calculations, improving the integration of veqpy with the existing plasma modeling framework. Additionally, logging has been added for better traceability of equilibrium state conditions.
This commit removes the direct instantiation of the `PlasmaEquilibrium` class from the `Models` and `Physics` classes, streamlining the plasma equilibrium handling. It introduces a new `plasma_equilibrium-copy.py` file that implements a fixed-boundary plasma equilibrium via optional Veqpy integration. The `check_process` function is updated to enforce validation checks for equilibrium conditions, ensuring user-defined inputs are correctly specified. Additionally, the `DataStructure` class is enhanced to include a `veqpy` attribute for managing equilibrium states, improving the overall integration of Veqpy within the plasma modeling framework.
This commit introduces a validation check in the `check_process` function to ensure that when the pedestal type is set to `GREENWALD_FRACTION` and the equilibrium solver is active (`i_equilibrium_solve = 1`), the user must provide absolute density values for pedestal and separatrix densities. An appropriate error is raised if these conditions are not met, enhancing the robustness of input handling in the plasma modeling framework.
This commit introduces new constants and methods to handle proton-boron fusion reactions in the physics model. It adds the Boron-11 mass constant and the energy calculation for the proton-boron reaction. Additionally, new attributes for tracking fusion reaction rates and power densities are included in the `PhysicsData` class. The `FusionReactionRate` class is updated with a method to calculate the fusion reaction rate for the proton-boron reaction, and relevant updates are made to the physics model to integrate these changes. Tests are also updated to ensure proper functionality of the new features.
This commit introduces a new input variable for radiation calculations in the physics model, specifically for the proton-boron fusion reaction. It adds the `i_calculate_radiation` variable to the `INPUT_VARIABLES` and updates the `PhysicsData` class to include a corresponding attribute. The physics model is enhanced to handle different radiation calculation methods based on this new input, allowing for more accurate modeling of radiation effects in plasma simulations. Additionally, relevant functions for calculating bremsstrahlung radiation are implemented, improving the overall functionality of the radiation power calculations.
…contributions This commit modifies the radiation power calculation functions to incorporate synchrotron radiation alongside bremsstrahlung radiation. The power density calculations for both the plasma core and outer regions are updated to reflect this enhancement, improving the accuracy of radiation modeling in plasma simulations.
This commit updates the physics model to include new scaling calculations for the L-H transition based on Takizuka 2004. It modifies the `INPUT_VARIABLES` to extend the `i_l_h_threshold` range, updates the `PhysicsData` class to accommodate additional power threshold values, and implements the corresponding methods for nominal, upper, and lower bounds in the `PlasmaConfinementTransition` model. These enhancements improve the accuracy of plasma transition modeling and expand the capabilities of the physics framework.
…threshold This commit improves the documentation for the L-H transition power threshold calculations in the `PlasmaConfinementTransition` model, providing detailed parameter descriptions and references for proton-boron fusion scaling. Additionally, a warning is added in the `check_process` function to alert users when the `i_l_h_threshold` is set to specific values without necessary corrections, enhancing user awareness and model accuracy.
…a geometry This commit introduces a new plasma geometry option (`i_plasma_geometry = 13`) that allows users to specify the last closed flux surface using discrete (R, Z) points. It includes the addition of `r_array` and `z_array` inputs, which are validated and processed to derive key plasma parameters such as `rmajor`, `rminor`, `kappa`, and `triang`. The implementation also tracks the number of LCFS points provided and updates relevant documentation to reflect these changes.
This commit refines the handling of the R_AND_Z_ARRAY plasma geometry model by moving the relevant calculations into the match-case structure. The logic for computing `kappa`, `triang`, `kappa95`, and `triang95` based on the last closed flux surface (LCFS) arrays is now encapsulated within the appropriate case, improving code organization and readability. The previous implementation using an if statement has been removed to streamline the code.
…olve. Plasma current: - Accept i_plasma_current = 0 and read the current from plasma_current_user_input. - Require that input to be positive, and allow it with negative triangularity. - Leave the existing scaling laws unchanged when another model is selected. Equilibrium: - Add i_equilibrium_solve. When it is 1, iterate the on-axis electron density and temperature in veqpy until their volume averages match the PROCESS targets. - Rebuild the profiles from those axis values. Scale the ion temperature by the volume-average ion-to-electron temperature ratio. - Take the density-weighted electron temperature, normalised internal inductance, and on-axis current density from the solved equilibrium.
- Revised comments to enhance understanding of the code, specifically regarding the integration of source for psin and the calculation of volume average <Bp^2>. - Improved readability by translating comments from Chinese to English and standardizing terminology.
- Introduced validation checks for user-specified plasma current and current profile index when `i_equilibrium_solve` is set to 1. - Enhanced the `Physics` class to compute the inboard and outboard toroidal magnetic fields based on the plasma equilibrium. - Updated the calculation of the total magnetic field at both inboard and outboard locations, ensuring accurate representation of plasma conditions.
This commit introduces a new static method `bootstrap_fraction_sauter_equilibrium` in the `PlasmaBootstrapCurrent` class to calculate the bootstrap fraction based on Sauter equilibrium conditions. Additionally, a new static method `diamagnetic_integral` is added to the `PlasmaDiamagneticCurrent` class for calculating the diamagnetic integral based on the plasma equilibrium. These enhancements improve the accuracy and functionality of the plasma current models, facilitating more detailed plasma behavior analysis.
This commit updates the import statements in `main.py`, `init.py`, and `physics.py` to ensure consistency and clarity. Additionally, it enhances the docstrings in `input.py`, `plasma_equilibrium.py`, and `plasma_current.py` to provide better context and error handling information. These changes improve code readability and maintainability across the project.
…ntegration This commit introduces a new `VeqpyRuntime` class to manage the latest veqpy equilibrium state and its associated axis iteration results. Additionally, it enhances the `plasma_equilibrium.py` file by adding functions to check the availability of veqpy equilibrium, clear transient results, and store equilibrium data. These changes improve the handling of plasma equilibrium states and facilitate better integration with veqpy functionalities.
This commit removes the direct instantiation of `PlasmaEquilibrium` from the `Models` and `Physics` classes, replacing it with a more integrated approach using the `VeqpyRuntime` class. It enhances the `Physics` class to utilize the new equilibrium management methods, ensuring that plasma equilibrium calculations are more streamlined and consistent with the latest veqpy functionalities. Additionally, validation checks for user inputs related to plasma equilibrium are updated to improve error handling.
This commit introduces a validation check in the `check_process` function to ensure that when the pedestal type is set to `GREENWALD_FRACTION` and the equilibrium solver is active (`i_equilibrium_solve = 1`), the user must provide absolute density values for pedestal and separatrix densities. An appropriate error is raised if these conditions are not met, enhancing the robustness of input handling in the plasma modeling framework.
…l_avg This commit updates the VeqpyRuntime class to include a new attribute for the volume-averaged electron density, f_temp_plasma_electron_density_vol_avg. The Physics and PlasmaEquilibrium classes are modified to store and utilize this new attribute during equilibrium calculations. Additionally, references to the equilibrium state are streamlined to improve consistency across the plasma modeling framework.
…tion This update adds a validation check in the check_process function to ensure that the deuterium, tritium, and helium-3 fuel ion fractions sum to zero. Additionally, it enhances the existing validation to include checks for boron-11 and proton fractions, raising a ProcessValidationError if the conditions are not met. This improves the robustness of the fuel ion fraction calculations.
…ions This commit introduces the run_pb_fusion method in the Physics class, which calculates essential plasma physics parameters for a tokamak fusion reactor. The method includes calculations for plasma composition, current, and safety factors, while also handling various plasma profiles and inductance. Additionally, it raises a ProcessValueError for illegal input values, enhancing error handling. This update significantly expands the functionality of the physics model, providing a comprehensive routine for plasma physics analysis.
…d accuracy This commit updates the docstring of the plasma_composition_pb method to provide a clearer description of its functionality, specifically focusing on the plasma composition for proton-boron-11 fuel. The method's calculations have been detailed, including adjustments for charge neutrality and the handling of various plasma components. Additionally, the error handling for input values has been refined to enhance robustness. These changes improve the documentation and maintainability of the physics model.
This commit updates variable names and calculations in the CurrentDrive, PlasmaReactions, and Physics classes to improve consistency and readability. Key changes include renaming power variables for electron Bernstein cases, enhancing fusion rate summation, and streamlining plasma density calculations. Additionally, obsolete checks related to proton-boron fusion reactions have been removed, and new density-weighted temperature calculations have been added to the PlasmaProfile class.
… PlasmaReactions This commit introduces new variables for volume-averaged p-B11 fusion reactivity and power density in the PhysicsData class. The PlasmaReactions class has been updated to calculate the p-B11 fusion reaction rates and power densities accurately. Additionally, references to obsolete variables have been removed, and the calculations have been streamlined for clarity and consistency across the physics model.
…peOffLayer This commit introduces early return conditions in the CurrentDrive and ScrapeOffLayer classes to handle cases where input parameters are zero. Specifically, it returns 0.0 for zero injected power in CurrentDrive and np.inf for zero plasma separatrix electron density in ScrapeOffLayer, improving the robustness of the calculations and preventing potential errors in further computations.
This commit introduces a new input variable for the proton-boron reactivity model in the PhysicsData class, allowing for two models: Nevins and Tentori-Belloni. The PlasmaReactions class has been updated to utilize the selected reactivity model in calculations, enhancing the accuracy of fusion reaction rates. Additionally, the range for the ion electron temperature input variable has been adjusted for consistency.
…n calculations This commit modifies the fsgmpb_tentori_belloni function by removing the conversion from keV to MeV and adjusting the return value to include a scaling factor. Additionally, the sigma calculation in the tentori_belloni_reactivity function is updated to use a list comprehension for better performance. These changes enhance the precision of the fusion reaction rate calculations.
This commit updates the Physics and radiation_power modules to enhance the accuracy of plasma calculations. Key changes include the introduction of edge interpolation weights for radial and vertical positions, and the renaming of variables for consistency. Additionally, the handling of bremsstrahlung radiation calculations has been refined by updating variable names and ensuring proper integration of density and temperature factors. These modifications improve the overall robustness and readability of the physics model.
This commit modifies the i_calculate_radiation variable in the PhysicsData class from 1 to 2, enabling profile or equilibrium integration for the p-B11 bremsstrahlung model. This change enhances the flexibility of radiation calculations, allowing for improved accuracy in plasma modeling.
This commit modifies the integration limits in the radiation power calculations, changing them from 0 to a small positive value (1.0e-5) to avoid singularities and enhance the accuracy of the bremsstrahlung power density calculations. This adjustment ensures more reliable results in plasma modeling.
This commit updates the PlasmaBootstrapCurrent model by modifying the calculation of the average magnetic field and the bootstrap current. The integration now incorporates the radial coordinate, enhancing the accuracy of the current density calculations. Additionally, variable names have been adjusted for clarity, ensuring better readability and consistency in the physics model.
…r accuracy This commit modifies the condition for the core density mask in the calculate_power_radiation function, changing the comparison from less than or equal to (< =) to strictly less than (<). This adjustment enhances the precision of the integration process in radiation power calculations, ensuring more accurate results in plasma modeling.
…xecution This commit introduces two new markdown files that outline the data flow for the PROCESS system and the execution sequence of the physics modules. The first document details user input requirements, data parsing, and the overall flow of data through the system, while the second document provides a structured overview of the physics module's execution, including necessary user inputs for various calculations. These additions enhance the clarity and usability of the documentation for developers and users working with the PROCESS system.
This commit introduces a new `run_model.py` file containing the `Models` and `RunModel` classes, which encapsulate various plasma physics models and their execution. Additionally, a new `trans_variables.py` file is added, providing transformation functions for density and pressure calculations in plasma physics. These additions enhance the modularity and functionality of the PROCESS system, facilitating more accurate plasma modeling and analysis.
…tions. This commit introduces error handling for the plasma fuel fractions (deuterium, tritium, and helium3) in the Physics model for pB reactions. If any of these values are non-zero, an error is logged, and the values are reset to 0.0. This enhancement ensures that invalid fuel fractions do not affect subsequent calculations, improving the robustness of the plasma modeling process.
… bore calculation This commit introduces the `bld.dr_shld_blkt_gap` variable to the Build model, ensuring it is included in both inboard and outboard calculations. Additionally, the calculation for `bld.dr_tf_inner_bore` has been corrected to use addition instead of subtraction for the inboard thickness, improving the accuracy of the model's geometry calculations.
This commit updates the logic for handling fusion reactions in the PlasmaReactions and Physics models. The plasma composition calculation is now conditionally executed based on the selected fusion reaction type, specifically for "d-t-he3" and "p-b11". Additionally, formatting improvements are made to the documentation references for better readability. These changes enhance the clarity and functionality of the plasma modeling process.
This commit improves the readability of the TFCoil model by adjusting the indentation of warning logs and correcting the calculation of the `len_tf_coil` variable. The changes ensure that the logic is clearer and more consistent, enhancing the overall maintainability of the code.
q95-prescribed scalings adjust the plasma current inside the solve, and the equilibrium then updates kappa95, triang95 and the poloidal perimeter. Write that current back and recompute qstar, the surface poloidal field and the internal inductance in the same call so later models use one consistent state. A fixed plasma-current input is left unchanged.
This commit introduces a new method to calculate the fraction of p-B11 alpha energy allocated to electrons and ions, utilizing classical slowing down from the mean birth energy. The previous implementation has been removed, and the logic has been updated for clarity and accuracy. Additionally, detailed documentation has been added to explain the new calculations and parameters involved.
This commit introduces the `rether_pb` function to calculate the volume-averaged ion-electron exchange power density for p-B11 fusion reactions. The implementation includes detailed parameter documentation and handles various conditions for density and temperature profiles. Additionally, unit tests for `rether_pb` are added to ensure accuracy across different scenarios, including uniform profiles, temperature differences, and equilibrium averages. This enhancement improves the modeling capabilities for p-B11 reactions in the Physics model.
A chained comparison had treated every aspect ratio above 2.5 as inside the fit, so 4.3 - 0.6A was also used above 4 and could become negative. Use that fit only for 2.5 < A < 4, and leave the neoclassical enhancement at 1 outside it.
The critical speed carried an extra density factor, and the electron slowing-down time was multiplied by the Coulomb-log ratio that already defines the critical energy. Integrate the fast-proton distribution up to the beam energy, apply the beam-fusion multiplier and PB_ENERGY once, and use the selected p-B11 reactivity model inside the beam-target integral. Rename the default fusion-reaction label to d-t-he3.
The IPDG89 fit leaves the neoclassical factor at 1 outside aspect ratios 2.5 to 4, so a spherical tokamak lost the trapped-particle enhancement. For p-B11, form the loop resistance from the volume-averaged Sauter neoclassical conductivity, using the equilibrium q and trapped fraction when they exist. The D-T-He3 path is unchanged.
- Introduced boron as a new fuel type in radiation power contributions. - Updated the physics data structure to include boron radiation power. - Modified impurity radiation calculations to account for boron as both a fuel and impurity depending on the fusion reaction. - Adjusted radiation power calculations to reflect changes in bremsstrahlung and synchrotron radiation handling for p-B11 reactions.
- Added checks to prevent division by zero when ion temperature is zero or negative, ensuring that thermal reactivity is set to zero in such cases. - Updated comments for clarity regarding the handling of cold points and cross-section calculations. - Adjusted the calculation of average reactivity to account for cases where reactivity is zero, preventing potential errors in subsequent computations.
…iation model - Implemented the calculation of p-B11 ion bremsstrahlung radiation power density using the Xie ion term. - Updated the ImpurityRadiation class to handle p-B11 reactions alongside D-T reactions. - Introduced a new function to assign p-B11 species radiation powers, integrating with existing physics data structures. - Enhanced comments for clarity on the handling of different fusion reactions and their impact on radiation power calculations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Checklist
I confirm that I have completed the following checks: