buildlukestruct_yp

PURPOSE ^

SYNOPSIS ^

function [varargout] = buildlukestruct_yp(loadstruct,equil,dkeparam_in,display,dkepath,ohm,waves,transpfaste,ripple,XXf0_in,XXsinksource_in)

DESCRIPTION ^

 Build main structures for LUKE that can be used also for other purposes

 INPUT
    - equil: axisymmetric toroidal magnetic equilibrium
    - dkeparam_in: dkeparam structure
    - display: dkedisplay structure
    - loadstruct: structure for reloading data already calculated. 

 OUTPUT: 
    - variable outputs depending upon the input mode

 By Yves Peysson (CEA-DRFC, yves.peysson@cea.fr) and Joan Decker (CEA-DRFC, joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [varargout] = buildlukestruct_yp(loadstruct,equil,dkeparam_in,display,dkepath,ohm,waves,transpfaste,ripple,XXf0_in,XXsinksource_in)
0002 %
0003 % Build main structures for LUKE that can be used also for other purposes
0004 %
0005 % INPUT
0006 %    - equil: axisymmetric toroidal magnetic equilibrium
0007 %    - dkeparam_in: dkeparam structure
0008 %    - display: dkedisplay structure
0009 %    - loadstruct: structure for reloading data already calculated.
0010 %
0011 % OUTPUT:
0012 %    - variable outputs depending upon the input mode
0013 %
0014 % By Yves Peysson (CEA-DRFC, yves.peysson@cea.fr) and Joan Decker (CEA-DRFC, joan.decker@cea.fr)
0015 %
0016 if ischar(loadstruct) && nargout ~= 1,
0017     error('There must be exactly one output argument in buildlukestruct_yp.m when a specific structure is requested.');
0018 end
0019 %
0020 dkeparam_out = paramconsistency_dke_yp(dkeparam_in,equil);%Check consistency between input parameters
0021 %
0022 % Load data if existing in 'loadstruct' structure or recalculate them if not exists
0023 %
0024 radialDKE = make_struct_jd(loadstruct,display.display_mode,'radialgrid_dke_jd',equil,dkeparam_out,display);%Radial grid for DKE
0025 equilDKE = make_struct_jd(loadstruct,display.display_mode,'equilibrium_jd',equil,radialDKE,display,'spline',dkeparam_out.mfactor);%Magnetic equilibrium for DKE
0026 momentumDKE = make_struct_jd(loadstruct,display.display_mode,'momentumgrid_dke_jd',dkeparam_out,equilDKE,radialDKE);%Momentum space 2D grid for DKE
0027 gridDKE = make_struct_jd(loadstruct,display.display_mode,'matrix3Dgridbuilder_dke_yp',dkeparam_out,display,equilDKE,radialDKE,momentumDKE);%General grid structure for the DKE solver
0028 %
0029 mksa = make_struct_jd(loadstruct,display.display_mode,'mksacoefbuilder_dke_yp',dkeparam_out,display,equilDKE,radialDKE);%MKSA quantities calculations
0030 if ischar(loadstruct) && strcmp(loadstruct,'mksa'),
0031     varargout{1} = mksa;
0032     return
0033 end
0034 %
0035 Zmomcoef = make_struct_jd(loadstruct,display.display_mode,'momentumcoefbuilder_dke_yp',gridDKE,mksa);%Momentum space coefficients for FP calculations
0036 if ischar(loadstruct) && strcmp(loadstruct,'Zmomcoef'),
0037     varargout{1} = Zmomcoef;
0038     return
0039 end
0040 %
0041 Zbouncecoef = make_struct_jd(loadstruct,display.display_mode,'bouncecoefbuilder_dke_yp',dkeparam_out,display,equilDKE,gridDKE);%bounce averaging coefficients
0042 if ischar(loadstruct) && strcmp(loadstruct,'Zbouncecoef'),
0043     varargout{1} = Zbouncecoef;
0044     return
0045 end
0046 %
0047 XXsinksource = make_struct_jd(loadstruct,display.display_mode,'sinksourcecoeffbuilder_dke_yp',dkeparam_out,display,gridDKE,mksa,Zbouncecoef,XXsinksource_in);%External sink and source contributions (for right-hand side part of the FP equation)
0048 Zmripple = make_struct_jd(loadstruct,display.display_mode,'mripplecoefbuilder_dke_yp',dkeparam_out,display,equil,equilDKE,gridDKE,mksa,ripple);%Magnetic ripple matrix coefficients
0049 [ZXXD_a,ZXXF_a] = make_struct_jd(loadstruct,display.display_mode,'rad_dke_yp',dkeparam_out,display,equilDKE,gridDKE,mksa,Zbouncecoef,Zmomcoef,transpfaste);%Anomalous radial transport super matrix
0050 [ZXXD_c,ZXXF_c,ZXXD_c_tp,ZXXF_c_tp,XXfM,XXILor] = make_struct_jd(loadstruct,display.display_mode,'coll_dke_jd',dkepath,dkeparam_out,display,equilDKE,mksa,gridDKE,Zmomcoef,Zbouncecoef);%Collisions flux coefficients
0051 [ZXXD_e,ZXXF_e,ZXXD_e_tp,ZXXF_e_tp,xepsi_init,xEfield_validity] = make_struct_jd(loadstruct,display.display_mode,'efield_dke_jd',dkepath,dkeparam_out,display,equilDKE,mksa,gridDKE,Zmomcoef,Zbouncecoef,ohm,ZXXF_c);%Electric field flux coefficients
0052 [ZXXD_s,ZXXF_s,ZXXD_s_tp,ZXXF_s_tp] = make_struct_jd(loadstruct,display.display_mode,'synchrotron_dke_jd',dkeparam_out,display,equilDKE,mksa,gridDKE,Zmomcoef,Zbouncecoef);%Synchrotron reaction flux coefficients
0053 [waveparam,xyprop_dke,xyP0_2piRp_mod,xyP0_2piRp_mod_coll,xyP0_2piRp_mod_noabs,yb,yP0_2piRp,xys] = make_struct_jd(loadstruct,display.display_mode,'rfwave_dke_jd',dkeparam_out,display,equil,equilDKE,gridDKE,Zbouncecoef,mksa,waves);%RF wave parameters preprocessing calculations
0054 %
0055 if isnan(dkeparam_out.pnmin0_KO) || dkeparam_out.pnmin0_KO > max(momentumDKE.pn_S),
0056     dkeparam_out.pnmin0_KO = max(momentumDKE.pn_S);%condition pnmin0_KO <= pnmax_S is enforced so that the source can be calculated
0057 end
0058 if isnan(dkeparam_out.pnmax2_KO),
0059     dkeparam_out.pnmax2_KO = dkeparam_out.pnmin0_KO;%condition pnmax2_KO <= pnmin0_KO ensure the separation of primary and secondary electrons
0060 end
0061 if isnan(dkeparam_out.pnmax1_KO),
0062     %dkeparam_out.pnmax1_KO = dkeparam_out.pnmin2_KO;%condition pnmax1_KO <= pnmin2_KO ensure secondary electrons gain energy
0063 end
0064 [XXSavalanches_norm,xnrem_init,xnrep_init,xnre_out_norm] = make_struct_jd(loadstruct,display.display_mode,'avalanche_en',dkepath,dkeparam_out,display,mksa,gridDKE,Zmomcoef,Zbouncecoef,ohm,equilDKE,radialDKE);%the complete avalanche operator
0065 %
0066 if strcmp(waveparam.model,'RT'),% ray tracing simulation
0067     [ZXYD_rf,ZXYF_rf,ZXYD_rf_tp,ZXYF_rf_tp,gridindex_rf] = make_struct_jd(loadstruct,display.display_mode,'loop_rfdiff_dke_jd',dkepath,dkeparam_out,display,equilDKE,gridDKE,Zmomcoef,Zbouncecoef,mksa,radialDKE,waveparam);%RF waves flux coefficients
0068 elseif strcmp(waveparam.model,'FW_BIL')%full wave model by R. Bilato
0069     [ZXYD_rf,ZXYF_rf,ZXYD_rf_tp,ZXYF_rf_tp,gridindex_rf] = make_struct_jd(loadstruct,display.display_mode,'rfdiff_dke_fw_jd',dkeparam_out,display,equilDKE,gridDKE,Zmomcoef,Zbouncecoef,mksa,radialDKE,waves);%RF waves flux coefficients
0070 else
0071   error('Wave model not implemented')
0072 end
0073 %
0074 [XXfinit] = make_struct_jd(loadstruct,display.display_mode,'finit_dke_yp',dkeparam_out,display,equilDKE,gridDKE,mksa,Zmomcoef,waveparam,XXf0_in);%Initial distribution function
0075 %
0076 varargout_loc = {dkeparam_out,radialDKE,equilDKE,momentumDKE,gridDKE,mksa,Zmomcoef,Zbouncecoef,...
0077                  XXsinksource,Zmripple,XXSavalanches_norm,xnrem_init,xnrep_init,xnre_out_norm,...
0078                  ZXXD_a,ZXXF_a,...
0079                  ZXXD_c,ZXXF_c,ZXXD_c_tp,ZXXF_c_tp,XXfM,XXILor,...
0080                  ZXXD_e,ZXXF_e,ZXXD_e_tp,ZXXF_e_tp,xepsi_init,xEfield_validity,...
0081                  ZXXD_s,ZXXF_s,ZXXD_s_tp,ZXXF_s_tp,...
0082                  waveparam,xyprop_dke,xyP0_2piRp_mod,xyP0_2piRp_mod_coll,xyP0_2piRp_mod_noabs,yb,yP0_2piRp,xys,...
0083                  ZXYD_rf,ZXYF_rf,ZXYD_rf_tp,ZXYF_rf_tp,gridindex_rf,...
0084                  XXfinit};
0085 %
0086 varargout = varargout_loc(1:nargout);
0087 %

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.