Repository navigation
Particle balance constraint #4139
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
9210e9a
Add new plasma physics variables and update iteration variable count
chris-ashe 9081e52
Add particle balance constraint equation and update constraint count
chris-ashe b28ffda
Add new plasma physics input variables for recycling and fuelling
chris-ashe 64a10a3
Refactor particle balance constraint equation and update iteration va…
chris-ashe 34947ac
Update particle balance constraints and increment equation count
chris-ashe ef39524
Update constraint limits
chris-ashe de9ac4e
Add new total D-T fusion rate variables
chris-ashe 4f1b0e1
Update consistency equations for particle consistency
timothy-nunn 209e824
Update molflow plasma fuelling variable ranges for consistency
chris-ashe 966b457
Refine fusion power output formatting for improved precision in plot …
chris-ashe 783f26b
Add D-D fusion reaction rate variables for helium and tritium branches
chris-ashe 8b4e744
Add D-D fusion rate calculations for tritium and helium branches
chris-ashe 6d974b4
Add plasma tritium flow rate calculations and contour plotting
chris-ashe 89a29b6
Add total D-D fusion rate calculation and update output formatting
chris-ashe 8cd99b6
Add deuterium and alpha particle flow rate calculations and contour p…
chris-ashe 0c821db
Add plotting of fuelling efficiency and recycling fraction in plasma …
chris-ashe d259c03
Add plasma fuelling equations and documentation
chris-ashe 54db27a
Add D-3He fusion rate and neutron production rate calculations
chris-ashe 9e9aa5e
Add fuelling composition variables and constraints for deuterium, tri…
chris-ashe d78757c
Enhance plasma flow calculations by adding tritium and deuterium flow…
chris-ashe 1b903ed
Rename burn-up fraction variable to f_plasma_fuel_burnup across multi…
chris-ashe 55d08f1
Refactor fuel burn-up rate variable to fusrat_total across multiple f…
chris-ashe e06b0a9
Refactor plasma exhaust calculations to plasma fuelling, updating rel…
chris-ashe 3ebde65
Refactor plasma fuelling plotting functions to improve organization a…
chris-ashe d8aec4d
Integrate PlasmaFuelling class into physics calculations and update f…
chris-ashe c88c865
Enhance plasma fuelling documentation with flow rate equations and ke…
chris-ashe 6772cea
Refactor fuelling output logic to use dedicated method in PlasmaFuell…
chris-ashe 32961f2
:fire: Remove tauratio variable from input variables and related test…
chris-ashe 659fb1b
Add tritium and deuterium burnup calculations and update physics vari…
chris-ashe 0760176
:fire: Refactor plasma fuelling variables: remove unused 'molflow_pla…
chris-ashe 3a91922
Add Avogadro's number constant with reference documentation
chris-ashe ebc45c1
Add plasma fuelling loss calculations and update related variables in…
chris-ashe 6aed3e6
Add helium-3 flow contour plotting and enhance existing contour plots…
chris-ashe b26a3e1
Refactor plotting indices in main_plot function to accommodate additi…
chris-ashe d594337
Enhance plasma fuelling documentation: add definitions for exhaust ef…
chris-ashe 694d95b
Refactor Physics model and unit tests to integrate PlasmaFuelling cla…
chris-ashe 6004cfb
Post rebase fixes
chris-ashe 4789875
post rebase fixes
chris-ashe af1ecc7
Enhance plasma fuelling documentation and update constraint equations…
chris-ashe 74eac1c
Enhance plasma fuelling documentation: add particle balance section, …
chris-ashe 6b5fa2c
Update large tokamak input file: adjust number of equality constraint…
chris-ashe 3e5c5fd
Fix bug in output caused by rebase
chris-ashe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1777,6 +1777,79 @@ def constraint_equation_92(constraint_registration, data): | |
| ) | ||
|
|
||
|
|
||
| @ConstraintManager.register_constraint(93, "particles/s", "=") | ||
| def constraint_equation_93(): | ||
| """ | ||
| Particle balance | ||
| """ | ||
| # pscaling: total transport power per volume (MW/m3) | ||
| # NEED TO ADD PROPER FUSION RATES FOR EACH REACTION | ||
|
|
||
| # Numerator shall be the tritium particle balance | ||
| numerator = ( | ||
| data_structure.physics_variables.eta_plasma_fuelling | ||
| * data_structure.physics_variables.molflow_plasma_fuelling_vv_injected | ||
| - data_structure.physics_variables.fusrat_total | ||
| ) - ( | ||
| ( | ||
| data_structure.physics_variables.nd_plasma_fuel_ions_vol_avg | ||
| * data_structure.physics_variables.vol_plasma | ||
| * data_structure.physics_variables.f_plasma_fuel_tritium | ||
| ) | ||
| / ( | ||
| data_structure.physics_variables.t_energy_confinement | ||
| / (1 - data_structure.physics_variables.f_plasma_particles_lcfs_recycled) | ||
| ) | ||
| ) | ||
|
|
||
| # Alpha particle balance | ||
| denominator = data_structure.physics_variables.fusrat_total - ( | ||
| data_structure.physics_variables.nd_plasma_alphas_vol_avg | ||
| * data_structure.physics_variables.vol_plasma | ||
| ) / (data_structure.physics_variables.t_alpha_confinement) | ||
|
|
||
| cc = 1.0 - numerator / numerator | ||
|
|
||
| return ConstraintResult(cc, denominator * (1.0 - cc), denominator * cc) | ||
|
|
||
|
|
||
| @ConstraintManager.register_constraint(93, "particles/s", "=") | ||
| def constraint_equation_93(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be a copy of the previous constraint. |
||
| """ | ||
| Particle balance | ||
| """ | ||
| # pscaling: total transport power per volume (MW/m3) | ||
| # NEED TO ADD PROPER FUSION RATES FOR EACH REACTION | ||
|
|
||
| # Numerator shall be the tritium particle balance | ||
| numerator = ( | ||
| data_structure.physics_variables.eta_plasma_fuelling | ||
| * data_structure.physics_variables.molflow_plasma_fuelling_vv_injected | ||
| - data_structure.physics_variables.fusrat_total | ||
| ) - ( | ||
| ( | ||
| data_structure.physics_variables.nd_plasma_fuel_ions_vol_avg | ||
| * data_structure.physics_variables.vol_plasma | ||
| * data_structure.physics_variables.f_plasma_fuel_tritium | ||
| ) | ||
| / ( | ||
| data_structure.physics_variables.t_energy_confinement | ||
| / (1 - data_structure.physics_variables.f_plasma_particles_lcfs_recycled) | ||
| ) | ||
| ) | ||
|
|
||
| # Alpha particle balance | ||
| denominator = data_structure.physics_variables.fusrat_total - ( | ||
| data_structure.physics_variables.nd_plasma_alphas_vol_avg | ||
| * data_structure.physics_variables.vol_plasma | ||
| ) / (data_structure.physics_variables.t_alpha_confinement) | ||
|
|
||
| cc = 1.0 - numerator / numerator | ||
|
|
||
| return ConstraintResult(cc, denominator * (1.0 - cc), denominator * cc) | ||
|
|
||
|
|
||
|
|
||
| def constraint_eqns(m: int, ieqn: int, data: DataStructure): | ||
| """Evaluates the constraints given the current state of PROCESS. | ||
|
|
||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,10 +99,105 @@ def description(self): | |
| return self._description_ | ||
|
|
||
|
|
||
| ipnvars: int = 177 | ||
| class PROCESSRunMode(IntEnum): | ||
| """Enumeration of the available PROCESS run modes, which determine the behaviour | ||
| of the code in various places. This is controlled by the `ioptimz` variable | ||
| """ | ||
|
|
||
| EVALUATION = (-2, "Evaluation mode (no optimisation)") | ||
| """In this mode, the code will not perform any optimisation, and will instead | ||
| simply evaluate the constraints for the given input parameters, which is useful | ||
| for testing and for evaluating the performance of a given design point without | ||
| trying to optimise it. Internally, PROCESS uses `fsolve` (a Newton-Krylov/hybrd | ||
| root-finding method from `scipy.optimize`) to seek a *consistent* solution by | ||
| varying a subset of the iteration variables until the consistency constraints | ||
| (equality constraints whose residuals must be driven to zero) are simultaneously | ||
| satisfied; no figure-of-merit is optimised, and the solver simply tries to find | ||
| a root of the constraint-residual vector. | ||
| """ | ||
| OPTIMISATION = (1, "Optimisation mode (e.g. via VMCON)") | ||
| """In this mode, the code will perform optimisation using the VMCON solver | ||
| (or a custom solver if specified) to try to find a design point that optimises | ||
| the figure of merit while satisfying the constraints. This is the default mode | ||
| of operation for PROCESS. | ||
| """ | ||
|
|
||
| def __new__(cls, value: int, description: str): | ||
| """Create a new PROCESSRunMode enum member with description. | ||
|
|
||
| Args: | ||
| value: The integer value of the enum member. | ||
| description: The description for this run mode. | ||
|
|
||
| Returns | ||
| ------- | ||
| The new enum member with attached description. | ||
| """ | ||
| obj = int.__new__(cls, value) | ||
| obj._value_ = value | ||
| obj._description_ = description | ||
| return obj | ||
|
|
||
| @DynamicClassAttribute | ||
| def description(self): | ||
| """Return the description for this run mode.""" | ||
| return self._description_ | ||
|
|
||
|
|
||
| class FiguresOfMerit(IntEnum): | ||
| """Enumeration of the available figures of merit (FoM) that can be used as | ||
| objective functions for optimisation in PROCESS. | ||
| """ | ||
|
|
||
| MAJOR_RADIUS = (1, "Plasma major radius (R₀)") | ||
| NEUTRON_WALL_LOAD = (3, "Neutron wall load") | ||
| P_TF_PLUS_P_PF = (4, "TF & PF coil power") | ||
| FUSION_GAIN_Q = (5, "Fusion gain (Qₚₗₐₛₘₐ)") | ||
| COST_OF_ELECTRICITY = (6, "Cost of electricity") | ||
| CAPITAL_COST = (7, "Plant capital cost") | ||
| ASPECT_RATIO = (8, "Plasma aspect ratio") | ||
| DIVERTOR_HEAT_LOAD = (9, "Divertor heat load") | ||
| TOROIDAL_FIELD = (10, "Plasma toroidal field on axis (B₀)") | ||
| TOTAL_INJECTED_POWER = (11, "Plasma total injected power (Pᵢₙⱼ)") | ||
| PULSE_LENGTH = (14, "Pulse length") | ||
| PLANT_AVAILABILITY_FACTOR = (15, "Plant availability factor") | ||
| MIN_R0_MAX_TAU_BURN = ( | ||
| 16, | ||
| "Linear combination of major radius (minimised) and pulse length (maximised)", | ||
| ) | ||
| NET_ELECTRICAL_OUTPUT = (17, "Plant net electrical output") | ||
| NULL_FIGURE_OF_MERIT = (18, "Null Figure of Merit") | ||
| MAX_Q_MAX_T_PLANT_PULSE_BURN = ( | ||
| 19, | ||
| "Linear combination of big Q and pulse length (maximised)", | ||
| ) | ||
|
|
||
| def __new__(cls, value: int, description: str): | ||
| """Create a new FiguresOfMerit enum member with description. | ||
|
|
||
| Args: | ||
| value: The integer value of the enum member. | ||
| description: The description for this figure of merit. | ||
|
|
||
| Returns | ||
| ------- | ||
| The new enum member with attached description. | ||
| """ | ||
| obj = int.__new__(cls, value) | ||
| obj._value_ = value | ||
| obj._description_ = description | ||
| return obj | ||
|
|
||
| @DynamicClassAttribute | ||
| def description(self): | ||
| """Return the description for this figure of merit.""" | ||
| return self._description_ | ||
|
|
||
|
|
||
| ipnvars: int = 180 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this belongs in this PR: it should be separate. |
||
| """total number of variables available for iteration""" | ||
|
|
||
| ipeqns: int = 92 | ||
| ipeqns: int = 93 | ||
| """number of constraint equations available""" | ||
|
|
||
| ipnfoms: int = 19 | ||
|
|
||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fixup into previous commit where these were created.