-
Notifications
You must be signed in to change notification settings - Fork 0
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
Strange behavior of TGLF with D-T ions #310
Comments
In case someone is wondering, having a single species with mass run2
|
Interesting. @gmstaebler needs to weigh in here. Something very strange is happening to TGLF when ions have similar but unequal mass. Consider this input file:
Note that the ion masses are 1.0 and 1.01. This gives completely absurd fluxes:
Making only a tiny change to equal mass: 1.0 and 1.0 gives a sensible result:
|
Hi Jeff and gacode list,
I would check to make sure the code was not compiled with openmp. This library converts to single precision when broadcasting. This may have no effect, since it is after the eigenoslver, but using the ZGEEV in single precision will give garbage.
When folks were trying to compute trace impurity diffusivities it was found that having two species with the same mass, charge and temperature was a problem for the eigensolver (ZGEEV failed). Even a small change to the mass would fix the issue. You are showing an opposite problem where having slightly different masses is giving odd results. I am surprised the case with both the same mass works. Note that the sum of the energy fluxes for the ions is about the same for both examples. This may be real since the slightly different masses but same concentration etc. would be expected to produce two eigenmodes of slightly different frequencies and almost the same growthrate.
For Pablo's case with counter ion energy fluxes this could be real. If you are close to the boundary between one species carrying the instability or the other (D ITG vs T ITG) the subdominant species can draw energy off of the most unstable one. The sum of the energy fluxes is still positive. I notice in Pablo's case that it has q~1 and is interchange unstable D(I)>0. This can cause odd behavior for the ballooning modes.
I recommend you set the vertical offset parameters to zero (ZETA_LOC= 9.44267E-05, S_ZETA_LOC=-7.56015E-03). The definition of the "midplane" in ballooning representation (theta_bal=0) is the elevation (Z0) were dR/dtheta=0. A finite S_ZETA (dZ0/dr) makes the metric |grad r| up/down asymmetric in theta. A finite vertical offset (ZETA) is equivalent having a finite radial wavenumber for the ballooning mode. You can eliminate this offset by shifting the zero of the ballooning angle. Only Z-Z0 is matters.
|
(sorry I clicked "send and close" before I could finish writing) Hi @gmstaebler, thanks for the discussion! I'm looking at the simple case that @jcandy proposed (I also run it electrostatic, to make it simpler) and I found the following. The linear growth rate and real frequency spectra are almost the same for both cases (blue with the unequal masses, red equal masses): If it's a compilation issue, we are facing the same problem at MIT and GA. |
Maybe check on of the higher ky cases linearly with CGYRO?
From: Pablo Rodriguez-Fernandez ***@***.***>
Date: Thursday, July 27, 2023 at 12:57 PM
To: gafusion/gacode ***@***.***>
Cc: Staebler, Gary ***@***.***>, Mention ***@***.***>
Subject: [EXTERNAL] Re: [gafusion/gacode] Strange behavior of TGLF with D-T ions (Issue #310)
This is the result of a scan of MASS_2 from 1.0 to 1.5. In the following plots, the color transitions from red (1.0) to blue (1.5).
image.png (view on web)<https://urldefense.us/v2/url?u=https-3A__github.com_gafusion_gacode_assets_20051119_933ebd8f-2D0ca0-2D4b39-2Daf19-2D3783b0466cc3&d=DwMCaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=oeuRADaXAsQ3sdYZ1H8MBFj5rBszAefFmjI2QqoKTK8&m=aQD9sdW5wlX6mKe8bdq9RRODadPEgtusup5iCGLe-SAMJtdPVYmWLKsY5liHXaJe&s=63L2pk9joKodUUCB_Hr4gMhAqX5qAnVo7i20SbpFstk&e=>
There are significant discontinuities in the total flux, which happens because a mode at ky~0.2 gets stabilized when the mass of the ion is (interestingly) above 1.25. The contributions to the changes in the total flux come from changes in the Qi spectrum below ky<0.4.
However, this discontinuity because of the ky=0.2 is a separate issue. At higher ky (0.6-0.8) is where we observe the strange behavior of the large-magnitude, opposite-sign contributions from both ions to the Qi spectrum. In the right most plot I have taken the minimum of the first ion flux spectrum and the maximum of the second ion flux spectrum, to evaluate if this behavior becomes stronger as the masses are more equal to each other. Indeed that's the case, as the mass approaches 1.0, the fluxes become asymptotically(?) very large.
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_gafusion_gacode_issues_310-23issuecomment-2D1653998188&d=DwMCaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=oeuRADaXAsQ3sdYZ1H8MBFj5rBszAefFmjI2QqoKTK8&m=aQD9sdW5wlX6mKe8bdq9RRODadPEgtusup5iCGLe-SAMJtdPVYmWLKsY5liHXaJe&s=yxQVO4L1JZM6diQBexE3bako9Ctnm0Ic3Wed1QgKj_c&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAEXJK2DT6DNBVGWZVOAACLXSKMXBANCNFSM6AAAAAA2XXGW6U&d=DwMCaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=oeuRADaXAsQ3sdYZ1H8MBFj5rBszAefFmjI2QqoKTK8&m=aQD9sdW5wlX6mKe8bdq9RRODadPEgtusup5iCGLe-SAMJtdPVYmWLKsY5liHXaJe&s=mqO7TfPu5JHSxXURQo6DFbmvIif4wYmuGnARgQNBGfc&e=>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
HI @gmstaebler, @nthoward and I have been running hundreds of nonlinear CGYRO simulations with ions of similar mass (D-T) and I don't think we have never seen a negative ion heat flux spectrum for any of the ions... In any case, another piece of relevant information to explore why this is happening is that it's related to the saturation rule and not to the linear physics. I run the exact same case with SAT0 (doing [Blue is SAT2 and red is SAT0] |
I'm using a similar input file that Jeff sent previously:
|
Hi Pablo
What is the spectrum plot in the figure? I see only deltaphi at top left but it is not zero.
Cheers
Marco
From: Pablo Rodriguez-Fernandez ***@***.***>
Date: Thursday, August 3, 2023 at 11:35 AM
To: gafusion/gacode ***@***.***>
Cc: Marco Muraca ***@***.***>, Mention ***@***.***>
Subject: Re: [gafusion/gacode] Strange behavior of TGLF with D-T ions (Issue #310)
Some more info on this issue.
The QL flux spectrum (top row) is exactly the same for SAT0 and SAT2. Both show the very odd negative-positive Qi for the two ion heat fluxes. As expected, as the linear physics was the same.
However, the reason why that doesn't show up in the Sum Flux spectrum (bottom row) for SAT0 is because the potential spectrum turns out to be equal to zero at that specific ky mode in SAT0. It's not zero in SAT2, which ends up amplifying the QL spectrum observation.
image.png (view on web)<https://github.com/gafusion/gacode/assets/20051119/68945d49-3a1a-4145-8889-e11318be3228>
This, to me, brings up back to the linear solver as the source for this behavior. It was just that SAT0 made the issue disappear because the saturated potential at that wavenumber was exactly zero.
Does this make sense? Am I interpreting correctly the content of the QL_flux_spectrum and sum_flux_spectrum output files?
—
Reply to this email directly, view it on GitHub<#310 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BBGRMB55OGJXODNTP3W2D7DXTPAMDANCNFSM6AAAAAA2XXGW6U>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Marco, delta phi for SAT0 is zero at the wavenumber with the very large QL Qi flux: ky~0.64 |
Pablo,
This is an interesting clue. It seams like there is a bug that the QL weights are not getting set to zero when the linear growthrate is zero. The SAT2 model does not usually go to zero at a ky where gamma_ky=0 but SAT0 does.
Gary
From: Pablo Rodriguez-Fernandez ***@***.***>
Date: Thursday, August 3, 2023 at 1:22 PM
To: gafusion/gacode ***@***.***>
Cc: Staebler, Gary ***@***.***>, Mention ***@***.***>
Subject: [EXTERNAL] Re: [gafusion/gacode] Strange behavior of TGLF with D-T ions (Issue #310)
Marco, delta phi for SAT0 is zero at the wavenumber with the very large QL Qi flux: ky~0.64
—
Reply to this email directly, view it on GitHub<https://urldefense.us/v2/url?u=https-3A__github.com_gafusion_gacode_issues_310-23issuecomment-2D1664356862&d=DwMCaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=oeuRADaXAsQ3sdYZ1H8MBFj5rBszAefFmjI2QqoKTK8&m=Uz6vuiGoWqzd2KYPsFT-9xMYSsLdVgZm9G3zrwkuFXCzXjcdeS7vfJW9TEYEJ0GR&s=0f-rl3WsJOtJSK_7KYml6_oioCJvW3c6A9RQ-3LQ2Dc&e=>, or unsubscribe<https://urldefense.us/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AAEXJK3LMOQ3LJ67VQY7ZCTXTPM6FANCNFSM6AAAAAA2XXGW6U&d=DwMCaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=oeuRADaXAsQ3sdYZ1H8MBFj5rBszAefFmjI2QqoKTK8&m=Uz6vuiGoWqzd2KYPsFT-9xMYSsLdVgZm9G3zrwkuFXCzXjcdeS7vfJW9TEYEJ0GR&s=hQ3kT60al9BpUqGD9pZhi9SOWyZZpsW6w2hWxS5iNYs&e=>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Interesting, thanks @tomneiser! |
When I first saw the onset of anomalous behaviour that got worse as m1-m2 -> 0, I thought it might be related to the TGLF eigensolver having problems when two eigenvalues are nearly equal |
There could be some kind of resonance problem with the TGLF eigensolver.
The initial value solvers like CGYRO do not usually converge (lock on) when there are two modes with similar growthrate. The result is set to zero by QLGYRO in this case. This is probably why you do not see this behavior in QLGYRO.
|
@gmstaebler this is something different, since are there are not two nearby physical eigenvalues in this case. The eigenvalue and eigenmodes should be smooth functions of m2-m1. However, TGLF seems to have an unphysical sensitivity to m2-m1. Of course it works properly in the limit m2-m1=0, so that is a clue. Also, you can reply to these issues directly using github (the interface is nice): |
@pabloprf The blue and green lines in the left panel of my plot are quasi-linear weights calculated with linear CGYRO, and they do show this same negative-positive QL weights behavior as TGLF. However, whenever I see this behavior for CGYRO the linear mode is stable (I set the linear CGYRO growth rate to zero whenever gamma<0, e.g. blue line in the right panel). And yes, the strange behavior happens independent of the TGLF linear solver. I hope it's a helpful clue that this behavior also happens in linear CGYRO (but is harmless due to zero growth rates). The linear TGLF growth rate spectrum of the most unstable mode (green line in the right panel) shows a branch jump at the offending ky, so it could be a weakness of the eigenvalue solver when there are two nearby modes. @pabloprf's most recent detailed plot (top left panel) shows two modes with similar eigenvalues in the offending region, so there could be some mass-dependent coupling between nearby modes in TGLF that's causing this. To find the bug I would start by looking at mass-dependent terms in the QL weight calculation |
An update on my investigation of this this. Lines 803 to 804 in 08ff9dc
and the phi_norm fromLine 712 in 08ff9dc
The magnitude of energy_weight for the ions is much larger than phi_norm , which explodes in the construction of the QL weight here:Line 843 in 08ff9dc
In fact, this behavior is already evident when plotting the most unstable eigenmode from the case with equal masses (blue) and the case with 1% difference (red). Note the 6 orders of magnitude difference in scale between the two plots, even if both correspond to the same eigenvalue ( If I set a minimum value of Line 619 in 08ff9dc
Then the issue at that wavenumber disappears and the case with I hope this is relevant for the experts in the room to figure out a solution! |
(To give some numbers to the magnitudes of I added these before line 841 in
And for the most unstable mode it results:
The large magnitude of |
Ah, so epsilon1 is what corrects the result in the limit m2-m1->0. I was puzzled at why the problem suddenly disappeared as the difference decreased. |
Without the epsilon1 limit, the problem because more pronounced as m2-m1->0 because
|
This looks to me a numerical problem of the eigenvalue solver that could be mitigated by increasing |
Hi Pablo,
In tglf_LS.f90 try replacing the line
zmat(i,j) = beta(jmax(imax))*amat(i,j)- &
(small +alpha(jmax(imax)))*bmat(i,j)
with
zmat(i,j) = beta(jmax(imax))*amat(i,j)- &
(alpha(jmax(imax)))*bmat(i,j)
if(i.eq.j)zmat(i,j) = zmat(i,j) - small
If this does not help then make small complex (small,small) to shift both real and impaginary parts.
This section is using a singular value approach to computing the eigenvector. Perhaps it is failing when the eigenvalues have very close frequencies. The other option is to have ZGGEV compute all of the eigenvectors but this is expensive.
|
I ran Jeff's file with the GFS solver and do not find the problem with energy fluxes.
Here is what I get
==========================================================
GFTM Version not available. OSX_VENTURA Darwin arm64
==========================================================
[Parsing data in input.gftm]
no mpi
D(R) = 2.1057E-03 D(I) = 3.8806E-03
kinetic species = 3 non-kinetic species = 0
Gam/Gam_GB Q/Q_GB Q_low/Q_GB Pi/Pi_GB S/S_GB
elec 2.5197E-01 6.3522E-01 6.1692E-01 -5.0651E-11 4.1637E-02
ion1 1.3113E-01 4.2036E+00 4.1543E+00 1.4286E-07 -2.1720E-02
ion2 1.2085E-01 4.1916E+00 4.1373E+00 2.0165E-07 -1.9916E-02
nbasis = 12 nu = 7 ne = 3
This is with mass difference of 0.01. I guess this implies a bug in the original solver that did not get reproduced in the new one. Both use the singular value method to compute eigenvectors.
|
This is helpful information and good news, thank you Gary! |
This is good! Thanks Gary. |
GFS is a new linear eigensolver that should be published soon. It is not installed as an option to TGLF yet.
I tried lowering the ion temperature gradient to see if the odd counter-balance energy fluxes would appear.
I did not see anything odd down to RLT=0.3. There is a singular behavior of the QL weights near marginal (wi << 1) since the QL weight goes like wi/((wr-wGK)^2 + wi^2) where Real(w)=wr, Im(w) = wi and wGK is the real velocity dependent drifts (no collisions). If wi is small and wr-wGK passes through zero there can be a resonant response ~ 1/wi. For TGLF I would not expect this to be possible because of the GLF closure that subtracts from wi. wi-> wi-wGLF. In GFS there are only collisions for dissipation.
|
Pablo,Here is what I get running the stand alone TGLF for this case
|
Note that SAT0 uses the total eigenvector as a normalization for the QL weights not the potential so that could make a big difference. The SAT2 linear eigenmodes are also different but SAT1 and SAT0 should be the same |
Hi Gary, Those values of running TGLF standalone are a bit different from what Jeff sent earlier in this thread, but your values also show the positive-negative Qi pair, which give very different results when compared to the GFS results you showed earlier. |
Also, while GFS is not available as a solver in TGLF, what do you recommend to avoid the potential bug? |
I think I found the trouble for the TGLF case. You have Q_LOC=1.03.
This case is interchange unstable DR and DI >0. This can have odd effects on ballooning modes.
If I raise Q_LOC until DR, DI <0 (about Q_LOC>1.2) the counteracting energy fluxes go away.
There is still too much difference in the ion fluxes for small mass difference but this quickly goes away with large mass difference.
I think the transport code needs to monitor DR, DI from TGLF and if they are positive the input value of Q_LOC needs to be increased. (you could just set a minimum of Q_LOC=1.3 without changing the Q_PRIME or P_PRIME.
Gary
|
When running TGLF for a plasma that has D and T as two separate ions, I realized that sometimes (like in the example I'll show below) the ion heat flux from one of the ions can be negative and almost of the same magnitude as the positive flux from the other ion. This produces weird results, particularly when scanning over one quantity (such as a/LTi) or when using in transport solvers (TGYRO/PORTALS).
The three
input.tglf
files I'll be discussing can be found here: https://www.dropbox.com/scl/fo/xym4q9hplxsr5ftjfj0ef/h?rlkey=fk4ybaneob1uzaxzffwr1653z&dl=0run0 - D and T as separate species, produces the following output:
run1 - Changing the masses so that both ions have a mass of
A=2.5
(1.25
in normalized units), produces:When we compare run0 (blue) and run1 (red), we can see that the issue is a few low-k modes that become stable in run0 and that lead to a negative portion of the ion heat flux spectrum.
This was run with SAT2 but I don't think that should matter, since the differences are observed in the linear stability plots already.
This can have a quite strong effect on parameter scans, as seen here for a a/LTi (changing all ion species simultaneously):
Does someone has an idea of why this is happening? As far as I can tell, the parameters of this run are not out of the ordinary.
This may be of interest to @cholland @mmuraca @AudreySaltzman @nthoward
The text was updated successfully, but these errors were encountered: