-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsource.m
More file actions
32 lines (29 loc) · 1.81 KB
/
source.m
File metadata and controls
32 lines (29 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function source(run, mass, mom, ener, mag, grav)
% This function sources the non-conservative terms in the MHD equations like gravitational potential
% and radiation terms. Effectively it provides the means to add terms that cannot be brought within
% the del operator, which is the foundation of the spatial fluxing routines.
%
%>< run data manager object. ImogenManager
%>< mass mass density FluidArray
%>< mom momentum density FluidArray(3)
%>< ener energy density FluidArray
%>< mag magnetic field density FluidArray(3)
%>< grav gravitational potential GravityArray
%--- Gravitational Potential Sourcing ---%
% If the gravitational portion of the code is active, the gravitational potential terms
% in both the momentum and energy equations must be appended as source terms.
if run.gravity.ACTIVE
enerSource = zeros(run.gridSize);
for i=1:3
momSource = run.time.dTime*mass.thresholdArray ...
.* grav.calculate5PtDerivative(i,run.DGRID{i});
enerSource = enerSource + momSource .* mom(i).array ./ mass.array;
mom(i).array = mom(i).array - momSource;
end
ener.array = ener.array - enerSource;
end
%--- Radiation Sourcing ---%
% If radiation is active, the radiation terms are subtracted, as a sink, from the energy
% equation.
ener.array = ener.array - run.time.dTime*run.fluid.radiation.solve(run, mass, mom, ener, mag);
end