wave_power_jd

PURPOSE ^

SYNOPSIS ^

function [waves,byisel] = wave_power_jd(dkeparam,wavefiles,byPnonabs)

DESCRIPTION ^

 INPUT
    - dkeparam structure
    - waves files structure

 OUTPUT:
    - waves structure

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [waves,byisel] = wave_power_jd(dkeparam,wavefiles,byPnonabs)
0002 %
0003 % INPUT
0004 %    - dkeparam structure
0005 %    - waves files structure
0006 %
0007 % OUTPUT:
0008 %    - waves structure
0009 %
0010 % By Joan Decker (CEA-DRFC, joan.decker@cea.fr) and Yves Peysson (CEA-DRFC, yves.peysson@cea.fr)
0011 %
0012 if nargin < 2,
0013     error('Wrong number of input arguments in wave_distribution_yp.m.');
0014 end
0015 %
0016 if nargin < 3,
0017     byPnonabs = NaN;
0018 end
0019 %
0020 nw = length(wavefiles);
0021 %
0022 waves = cell(1,nw);
0023 %
0024 for iw = 1:nw,
0025     data = load(wavefiles{iw});
0026     waves{iw} = data.wave;
0027 end
0028 %
0029 if isfield(dkeparam,'enforcepower') && dkeparam.enforcepower,
0030     %
0031     % Initial power in the waves
0032     %
0033     ny = zeros(1,nw);
0034     yPtot_inj = cell(1,nw);
0035     %
0036     for iw = 1:nw,% for each wave
0037         %
0038         wave = waves{iw};
0039         %
0040         % initialize non-absorbed power in each ray
0041         %
0042         if isfield(wave.rayinit.launch,'bPlhtot'),%LH wave
0043             ny(iw) = length(wave.rayinit.launch.bPlhtot);
0044             yPtot_inj{iw} = wave.rayinit.launch.bPlhtot;%LH injected power at t=itn
0045         elseif isfield(wave.rayinit.launch,'yP_L'),%EC wave
0046             ny(iw) = length(wave.rayinit.launch.yP_L);
0047             yPtot_inj{iw} = wave.rayinit.launch.yP_L;%EC injected power at t=itn
0048         end
0049     end
0050     %
0051     % Add non-absorbed power from last simulation
0052     %
0053     if ~iscell(byPnonabs),% first time step, with fluctuations
0054         byPnonabs = cell(1,nw);
0055         for iw = 1:nw,% for each wave
0056             byPnonabs{iw} = zeros(1,ny(iw));
0057         end
0058     end
0059     %
0060     % byPnonabs contains the power not absorbed
0061     %
0062     if iscell(byPnonabs),%calculate fluctuation phases and adjust initial power in each ray
0063         for iw = 1:nw,
0064             waves{iw} = mod_wave_power_jd(waves{iw},yPtot_inj{iw} + byPnonabs{iw});
0065         end
0066     end    
0067     %
0068     % identify rays and lobes/beams
0069     %
0070     byisel = cell(1,nw);
0071     iray = 0;
0072     for iw = 1:nw,
0073         wave = waves{iw};
0074         %
0075         byisel{iw} = cell(1,ny);
0076         %
0077         for iy = 1:ny,
0078             byisel{iw}{iy} = [];
0079         end
0080         %
0081         % byisel contains the ray number belonging to the same lobe with possibly different launching positions (LH) or
0082         % to the same beam with different beamlets (EC)
0083         %
0084         for ib = 1:length(wave.rays),
0085             iray = iray+1;
0086             %
0087             iy = wave.rays{ib}.rayinits{1}.yib;
0088             %
0089             byisel{iw}{iy} = [byisel{iw}{iy},iray];
0090         end
0091     end
0092 else
0093     byisel = NaN;
0094 end
0095 %

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