Skip to content
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

Remove parfor in calcEnergyMap heat.m #17

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
19 changes: 12 additions & 7 deletions classes/heat.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
obj.heatDiffusion = p.Results.heatDiffusion;
obj.intpAtInterface = p.Results.intpAtInterface;
% set default ode options after initialization of parent class
obj.odeOptions.RelTol = 1e-3;
obj.odeOptions.RelTol = 1e-4;
end%function

%% Display
Expand Down Expand Up @@ -635,7 +635,8 @@ function setBoundaryCondition(obj,varargin)
index = finderb(z,dStart);
unitCell = handles{index}; % this is the handle to the corresponding unitCell

k = cellfun(@feval,(unitCell.thermCond)',num2cell(T));
k = cellfun(@feval,(unitCell.thermCond)',repmat({T},K,1)); % NTM
% k = cellfun(@feval,(unitCell.thermCond)',num2cell(T)); % 1TM
% these are the parameters of the differential equation as they
% are defined in matlab for the pdesolver

Expand Down Expand Up @@ -699,7 +700,7 @@ function setBoundaryCondition(obj,varargin)
%% getEnergyMap
% Returns an energy profile for the sample structure after
% optical excitation.
function energyMap = getEnergyMap(obj,time,excitation,initTemp,tempMap)
function energyMap = getEnergyMap(obj,time,excitation,initTemp,tempMap,includeSubstrate)
% create a unique hash
hash = obj.getHash(time,excitation,initTemp);
% create the file name to look for
Expand All @@ -710,7 +711,7 @@ function setBoundaryCondition(obj,varargin)
obj.dispMessage(['_energyMap_ loaded from file ' filename]);
else
% file does not exist so calculate and save
energyMap = obj.calcEnergyMap(tempMap,initTemp);
energyMap = obj.calcEnergyMap(tempMap,initTemp,includeSubstrate);
save(filename,'energyMap');
obj.dispMessage(['_energyMap_ saved to file ' filename]);
end
Expand All @@ -719,7 +720,7 @@ function setBoundaryCondition(obj,varargin)
%% calcEnergyMap
% Calculates the energy profile for the sample structure after
% optical excitation.
function energyMap = calcEnergyMap(obj,tempMap,initTemp)
function energyMap = calcEnergyMap(obj,tempMap,initTemp,includeSubstrate)

disp('Calculating _energyMap_ ...')
tic
Expand All @@ -731,10 +732,14 @@ function setBoundaryCondition(obj,varargin)
aAxes = obj.S.getUnitCellPropertyVector('aAxis');
bAxes = obj.S.getUnitCellPropertyVector('bAxis');
UCmasses = normMasses.*(aAxes/1e-10).*(bAxes/1e-10); % calculates vector of unit cell masses
Cells = obj.S.getNumberOfUnitCells;
if includeSubstrate
Cells = obj.S.getNumberOfUnitCells;
else
Cells = obj.S.getNumberOfUnitCells - length(obj.S.getAllPositionsPerUniqueUnitCell{end});
end

for k=1:obj.S.numSubSystems
parfor i=1:size(tempMap,1)
for i=1:size(tempMap,1)
for n=1:Cells
energyMap(i,n,k) = UCmasses(n)*( intHeatCapacity{n,k}(tempMap(i,n,k)) - intHeatCapacity{n,k}(initTemp(n,k)) );
end
Expand Down
5 changes: 4 additions & 1 deletion classes/phonon.m
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ function disp(obj)
% current temperature for each subsystem
% traverse subsystems
for j=1:K
intAlphaT(:,j) = cellfun(@feval,intLinThermExps(:,j),num2cell(squeeze(tempMap(i,:,j))'));
% traverse unit cells
for n=1:N
intAlphaT(n,j) = intLinThermExps{n,j}(tempMap(i,n,j)); % cellfun(@feval,intLinThermExps(:,j),num2cell(squeeze(tempMap(i,:,j))'));
end
end%for

% calculate the length of the sticks of each subsystem and sum
Expand Down
2 changes: 2 additions & 0 deletions classes/unitCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
obj.debWalFac{k} = str2func('@(T)(0.*T./T)');
obj.debWalFac(2) = debWalFacInit;
end%for
else
obj.debWalFac = debWalFacInit;
end%if

% calculate the area of the unit cell
Expand Down
2 changes: 1 addition & 1 deletion helpers/functions/finderb.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%% finderb
% Binary search algorithm for sorted lists.
% Searches for the first index _i_ of list where _key_ >= _list(i)_.
% Searches for the first index _i_ of list where _key_ <= _list(i)_.
% _key_ can be a scalar or a vector of keys.
% _list_ must be a sorted vector.
% author: Andr� Bojahr
Expand Down