ProjectTorreyPines / FUSE.jl

FUsion Synthesis Engine
https://fuse.help/
Apache License 2.0
9 stars 0 forks source link

Introduce stop condition for the FluxMatcher iterations? #670

Open avdeevag opened 1 month ago

avdeevag commented 1 month ago

I noticed that sometimes the flux matching solution is significantly better with less number of iterations than we have in default settings (see illustration below). If it is not too difficult maybe some conditions (based on the reached tolerance for total residual?) can be implemented to the FluxMatcher to stop on the optimal number of iterations?

Solution with 300 iterations for the ITER case Screenshot 2024-07-26 at 2 06 51 PM

versus default 500 iterations

Screenshot 2024-07-26 at 2 25 03 PM

Script to reproduce these cases

chk = FUSE.Checkpoint();

ini, act=FUSE.case_parameters(:ITER, init_from=:scalars, boundary_from=:scalars);

dd = IMAS.dd();
FUSE.init(dd, ini, act);

chk[:init] = dd,ini,act;

R6="sat2_es_mastu_azf+1";

dd_R1,ini_R1,act_R1 = chk[:init];

#----------------------

act_R1.ActorTGLF.user_specified_model = R6

act_R1.ActorCoreTransport.model = :FluxMatcher
#act_R1.ActorFluxMatcher.max_iterations = :300
#act_R1.ActorFluxMatcher.optimizer_algorithm = :simple
display(act_R1.ActorFluxMatcher)

FUSE.ActorPFdesign(dd_R1, act_R1);
FUSE.ActorStationaryPlasma(dd_R1, act_R1);

FUSE.plot_plasma_overview(dd_R1)
orso82 commented 1 month ago

@avdeevag could you please try running with act_R1.ActorFluxMatcher.do_plot=true and report how the convergence plot looks?

avdeevag commented 1 month ago

If I do act_R1.ActorFluxMatcher.do_plot=true it does not produce any plots when i run FUSE.ActorStationaryPlasma(dd_R1, act_R1); So, I run FUSE.ActorFluxMatcher(dd_R1, act_R1, do_plot=true) before the SationaryPlasma

Screenshot 2024-07-29 at 2 09 25 PM

and after

Screenshot 2024-07-29 at 2 06 46 PM
TimSlendebroek commented 1 month ago

Looks like we take collect(res.zero),

But like you discvoered maybe when it fails it doesnt' take the best one and uses the last