From 167b650b3a120fa6f3bf7c8a42fb3d373ae40485 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 14 Feb 2024 11:29:24 +0000 Subject: [PATCH 1/9] ncore warning --- process/profiles.py | 14 ++++---------- process/utilities/errorlist.json | 7 ++++++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/process/profiles.py b/process/profiles.py index 339c30f76..499fb517a 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -3,10 +3,7 @@ from scipy import integrate from abc import ABC, abstractmethod -from process.fortran import ( - maths_library, - physics_variables, -) +from process.fortran import maths_library, physics_variables, error_handling logger = logging.getLogger(__name__) # Logging handler for console output @@ -159,12 +156,9 @@ def ncore(rhopedn, nped, nsep, nav, alphan): # Prevent ncore from going negative (and terminating the optimisation) by # kludging to small positive value. Allows solver to continue and # hopefully be constrained away from this point (e.g. constraint 81, ne0 > neped) - logger.exception("ncore is negative. Kludging to 1e-6.") - ncore = 1.0e-6 - # raise ValueError( - # f"Core density is negative: {ncore}. {nped = }, {nsep = }, {nav = }" - # ) - return ncore + print("hello") + error_handling.report_error(252) + return def set_physics_variables(self): """_summary_ diff --git a/process/utilities/errorlist.json b/process/utilities/errorlist.json index c85fb76c8..b5e782efd 100644 --- a/process/utilities/errorlist.json +++ b/process/utilities/errorlist.json @@ -8,7 +8,7 @@ "comment2": [ "Increment n_errortypes if an error is added to this list" ], - "n_errortypes": 281, + "n_errortypes": 282, "errors": [ { "no": 1, @@ -1414,6 +1414,11 @@ "no": 281, "level": 3, "message": "CHECK: Cannot have i_tf_bucking >= 2 when tf_in_cs = 1" + }, + { + "no": 282, + "level": 3, + "message": "CHECK: ncore is going negative when solving. Please raise the value of dene and/or its lower limit." } ] } From 3b33e4d192ea57eb524dcbec6ecf24317ea39533 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 14 Feb 2024 11:39:37 +0000 Subject: [PATCH 2/9] syntax fix --- process/profiles.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/process/profiles.py b/process/profiles.py index 499fb517a..8af28f0f0 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -152,13 +152,12 @@ def ncore(rhopedn, nped, nsep, nav, alphan): ) ) - if ncore < 0: + if ncore < 0.0: # Prevent ncore from going negative (and terminating the optimisation) by # kludging to small positive value. Allows solver to continue and # hopefully be constrained away from this point (e.g. constraint 81, ne0 > neped) print("hello") - error_handling.report_error(252) - return + error_handling.report_error(282) def set_physics_variables(self): """_summary_ From 2ba076e0155b4df9d741b5f35447166ea481517c Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 14 Feb 2024 13:08:25 +0000 Subject: [PATCH 3/9] return ncore --- process/profiles.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/process/profiles.py b/process/profiles.py index 8af28f0f0..e63095ab4 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -124,7 +124,9 @@ def calculate_profile_y(self, rho, rhopedn, n0, nped, nsep, alphan): ) @staticmethod - def ncore(rhopedn, nped, nsep, nav, alphan): + def ncore( + rhopedn: float, nped: float, nsep: float, nav: float, alphan: float + ) -> float: """This routine calculates the core denesity of a pedestalised profile. :param rhopedn: normalised minor radius pedestal position @@ -156,9 +158,10 @@ def ncore(rhopedn, nped, nsep, nav, alphan): # Prevent ncore from going negative (and terminating the optimisation) by # kludging to small positive value. Allows solver to continue and # hopefully be constrained away from this point (e.g. constraint 81, ne0 > neped) - print("hello") error_handling.report_error(282) + return ncore + def set_physics_variables(self): """_summary_ Calculates and sets physics vcariables required for the profile. From bf25b7cd2d3e9b6021d1890fec739ddb9a2fff2d Mon Sep 17 00:00:00 2001 From: mn3981 Date: Wed, 14 Feb 2024 13:08:53 +0000 Subject: [PATCH 4/9] change error type --- process/utilities/errorlist.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/process/utilities/errorlist.json b/process/utilities/errorlist.json index 2771b9a6a..d39f74ed1 100644 --- a/process/utilities/errorlist.json +++ b/process/utilities/errorlist.json @@ -1417,8 +1417,8 @@ }, { "no": 282, - "level": 3, - "message": "CHECK: ncore is going negative when solving. Please raise the value of dene and/or its lower limit." + "level": 2, + "message": "CHECK: ncore is going negative when solving. Please raise the value of dene and or its lower limit." } ] } From 52fd0de2f323c341c3a51b08387b936e92915d91 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Thu, 15 Feb 2024 08:48:55 +0000 Subject: [PATCH 5/9] tidy up --- process/profiles.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/process/profiles.py b/process/profiles.py index e63095ab4..b0b7d556e 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -137,11 +137,10 @@ def ncore( :type nsep: float :param nav: electron density (/m3) :type nav: float - :param alphan: _description_ :param alphan: density peaking parameter :type alphan: float :return: Core density - :rtype: numpy.array + :type: float """ ncore = ( @@ -159,7 +158,6 @@ def ncore( # kludging to small positive value. Allows solver to continue and # hopefully be constrained away from this point (e.g. constraint 81, ne0 > neped) error_handling.report_error(282) - return ncore def set_physics_variables(self): From cc821c0e031b7975bbaff87eb0d22302c80e7b61 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Thu, 15 Feb 2024 10:28:33 +0000 Subject: [PATCH 6/9] update docs --- documentation/proc-pages/physics-models/plasma.md | 5 +++++ process/profiles.py | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/proc-pages/physics-models/plasma.md b/documentation/proc-pages/physics-models/plasma.md index fff2c5ee3..9ae5863f1 100644 --- a/documentation/proc-pages/physics-models/plasma.md +++ b/documentation/proc-pages/physics-models/plasma.md @@ -267,6 +267,11 @@ simulations. If `ipedestal` = 1 or 2 then the pedestal density `neped` is set as a fraction `fgwped` of the Greenwald density (providing `fgwped` >= 0). The default value of `fgwped` is 0.8[^7]. +!!! warning " Un-realistic profiles" + + If `ipedestal >= 1` it is highly recommended to use constraint equation 81 (icc=81). This enforces solutions in which $n_0$ has to be greater than $n_{ped}$. + Negative $n_0$ values can also arise during iteration, so it is important to be weary on how low the lower bound for $n_e (\mathtt{dene})$ is set. + ## Beta Limit The plasma beta limit[^7] is given by diff --git a/process/profiles.py b/process/profiles.py index b0b7d556e..f426c9b49 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -154,9 +154,8 @@ def ncore( ) if ncore < 0.0: - # Prevent ncore from going negative (and terminating the optimisation) by - # kludging to small positive value. Allows solver to continue and - # hopefully be constrained away from this point (e.g. constraint 81, ne0 > neped) + # Allows solver to continue and + # warns the user to raise the lower bound on dene if the run did not converge error_handling.report_error(282) return ncore From 9f319f4640c8d91143a779fa13deb693fe75ec5b Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 20 Feb 2024 09:38:23 +0000 Subject: [PATCH 7/9] updated bounds of pedestal params --- source/fortran/iteration_variables.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/fortran/iteration_variables.f90 b/source/fortran/iteration_variables.f90 index 72df52766..2e38e3a2d 100755 --- a/source/fortran/iteration_variables.f90 +++ b/source/fortran/iteration_variables.f90 @@ -148,7 +148,7 @@ subroutine init_itv_6 use numerics, only: lablxc, boundl, boundu implicit none lablxc(6) = 'dene ' - boundl(6) = 1.00D19 + boundl(6) = 2.00D19 boundu(6) = 1.00D21 end subroutine init_itv_6 @@ -3244,8 +3244,8 @@ subroutine init_itv_145 use numerics, only: lablxc, boundl, boundu implicit none lablxc(145) = 'fgwped ' - boundl(145) = 0.500D0 - boundu(145) = 1.000D0 + boundl(145) = 0.100D0 + boundu(145) = 0.75D0 end subroutine init_itv_145 real(kind(1.d0)) function itv_145() @@ -3377,7 +3377,7 @@ subroutine init_itv_152 implicit none lablxc(152) = 'fgwsep ' boundl(152) = 0.001D0 - boundu(152) = 1.000D0 + boundu(152) = 0.1D0 end subroutine init_itv_152 real(kind(1.d0)) function itv_152() From 15677528de537ab3a1c0d8ee71829b5d5238da54 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 20 Feb 2024 10:37:22 +0000 Subject: [PATCH 8/9] add ncore = 1E-6 back in --- process/profiles.py | 1 + 1 file changed, 1 insertion(+) diff --git a/process/profiles.py b/process/profiles.py index f426c9b49..5e8947048 100644 --- a/process/profiles.py +++ b/process/profiles.py @@ -157,6 +157,7 @@ def ncore( # Allows solver to continue and # warns the user to raise the lower bound on dene if the run did not converge error_handling.report_error(282) + ncore = 1.0e-6 return ncore def set_physics_variables(self): From 229fddac0e73a7aa4d106f298b7443c7d3691273 Mon Sep 17 00:00:00 2001 From: mn3981 Date: Tue, 20 Feb 2024 10:47:33 +0000 Subject: [PATCH 9/9] re-update pedestal bounds --- source/fortran/iteration_variables.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/fortran/iteration_variables.f90 b/source/fortran/iteration_variables.f90 index 2e38e3a2d..08070f13b 100755 --- a/source/fortran/iteration_variables.f90 +++ b/source/fortran/iteration_variables.f90 @@ -3245,7 +3245,7 @@ subroutine init_itv_145 implicit none lablxc(145) = 'fgwped ' boundl(145) = 0.100D0 - boundu(145) = 0.75D0 + boundu(145) = 0.9D0 end subroutine init_itv_145 real(kind(1.d0)) function itv_145() @@ -3377,7 +3377,7 @@ subroutine init_itv_152 implicit none lablxc(152) = 'fgwsep ' boundl(152) = 0.001D0 - boundu(152) = 0.1D0 + boundu(152) = 0.5D0 end subroutine init_itv_152 real(kind(1.d0)) function itv_152()