-
Notifications
You must be signed in to change notification settings - Fork 0
Description
QL-Balance modifies the input profile files in ./profiles/ during execution. This is important to understand when preparing runfolders or debugging unexpected profile changes.
What Happens
During time evolution (and other run types), QL-Balance:
- Reads profile data from
./profiles/*.datfiles - Interpolates profiles onto its internal computational grid
- Writes the resampled profiles back to
./profiles/*.dat
The affected files are:
n.dat(density)Te.dat(electron temperature)Ti.dat(ion temperature)Vz.dat(toroidal velocity)Vth.dat(poloidal velocity)Er.dat(radial electric field)q.dat(safety factor)
Note: Da.dat (anomalous diffusion coefficient) is not overwritten.
Technical Details
Code Location
The profile overwriting occurs in:
src/base/wave_code_data_64bit.f90:187-237
subroutine update_background_files(path)
...
integer :: flag = 1; ! always keep flag =1, since KiLCA reads profiles from ./profile directory
...
open (20, file=trim(path)//'n.dat');
open (30, file=trim(path)//'Te.dat');
! ... etc for all profile files
do k = 1, dim_r
write (20, *) r(k), n(k);
write (30, *) r(k), Te(k);
! ... etc
end doCall Chain
time_evolution.f90callsget_dql()get_dql.f90:137callsupdate_background_files(path2profs)whenirf == 1path2profsdefaults to'./profiles/'
The irf flag is set to 1 after the first initialization call, so profiles are overwritten on every subsequent get_dql call during time evolution.
Grid Resampling
The internal grid is determined by:
rminandrmaxfrombalance_conf.nmlnpoimin(minimum number of grid points)- Grid spacing:
(rmax - rmin) / (npoimin + 1)
This means:
- If you change
rmaxin the config, the output profiles will have a different radial extent - The number of grid points may change
- Profile values are interpolated to the new grid
Practical Implications
Example Scenario
- You have profiles extending from 3 to 67 cm with 11,314 points
- You change
rmaxfrom 67 to 61 inbalance_conf.nml - You run
./ql-balance - Your profile files now extend from 3 to 61 cm with ~12,173 points
The profiles are permanently modified!
Recommendations
- Keep backups: Always keep a backup of your original profile files before running QL-Balance
- Use separate directories: Consider keeping master profiles in a separate location and copying them to the runfolder before each run
- Version control: Track profile files in git if they are generated/processed data
- Be aware when debugging: If profiles look different after a run, this is expected behavior
Why This Exists
The comment in the code states:
! always keep flag =1, since KiLCA reads profiles from ./profile directoryThis suggests the feature exists to ensure KiLCA (which may be called during the run) has access to profiles on the same grid that QL-Balance uses internally.
See Also
src/base/wave_code_data_64bit.f90- Profile I/O implementationsrc/base/get_dql.f90- Whereupdate_background_filesis calledsrc/base/gengrid.f90- Grid generation logic