Skip to content

Commit

Permalink
updated sources to specify type of distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
kltrbrds committed Apr 20, 2021
1 parent 96013e3 commit 1b5f7ce
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 57 deletions.
27 changes: 22 additions & 5 deletions App/Sources/GkSource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,28 @@ function GkSource:fullInit(speciesTbl)
self.density = assert(tbl.density, "App.GkSource: must specify density profile of source in 'density'.")
self.temperature = assert(tbl.temperature, "App.GkSource: must specify temperature profile of source in 'density'.")
self.power = tbl.power
self.profile = Projection.GkProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
if tbl.type then
if tbl.type == "Maxwellian" or tbl.type == "maxwellian" then
self.profile = Projection.GkProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
else
print("App.GkSource: Source type not recognized, defaulting to Maxwellian.")
self.profile = Projection.GkProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
end
else
self.profile = Projection.GkProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
end
self.tmEvalSrc = 0.0
end

Expand Down
27 changes: 22 additions & 5 deletions App/Sources/VmSource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,28 @@ function VmSource:fullInit(speciesTbl)
self.density = assert(tbl.density, "App.VmSource: must specify density profile of source in 'density'.")
self.temperature = assert(tbl.temperature, "App.VmSource: must specify temperature profile of source in 'density'.")
self.power = tbl.power
self.profile = Projection.VlasovProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
if tbl.type then
if tbl.type == "Maxwellian" or tbl.type == "maxwellian" then
self.profile = Projection.VlasovProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
else
print("App.VmSource: Source type not recognized, defaulting to Maxwellian.")
self.profile = Projection.VlasovProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
end
else
self.profile = Projection.VlasovProjection.MaxwellianProjection {
density = self.density,
temperature = self.temperature,
power = self.power,
}
end
self.tmEvalSrc = 0.0
end

Expand Down
4 changes: 2 additions & 2 deletions App/Species/GkSpecies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ function GkSpecies:advance(tCurr, species, emIn, inIdx, outIdx)
self.timers.sources = self.timers.sources + Time.clock() - tm
end
if self.evolveSources then
for _, s in pairs(self.sources) do
s:advance(tCurr, fIn, species, fRhsOut)
for _, src in pairs(self.sources) do
src:advance(tCurr, fIn, species, fRhsOut)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions App/Species/KineticSpecies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,17 @@ function KineticSpecies:setConfBasis(basis)
for _, c in pairs(self.collisions) do
c:setConfBasis(basis)
end
for _, s in pairs(self.sources) do
s:setConfBasis(basis)
for _, src in pairs(self.sources) do
src:setConfBasis(basis)
end
end
function KineticSpecies:setConfGrid(grid)
self.confGrid = grid
for _, c in pairs(self.collisions) do
c:setConfGrid(grid)
end
for _, s in pairs(self.sources) do
s:setConfGrid(grid)
for _, src in pairs(self.sources) do
src:setConfGrid(grid)
end
end

Expand Down Expand Up @@ -1019,8 +1019,8 @@ function KineticSpecies:write(tm, force)
self.distf[1]:accumulate(1, self.f0)
end
if tm == 0.0 and self.fSource then
for _, s in pairs(self.sources) do
s:write(tm, self.distIoFrame, self)
for _, src in pairs(self.sources) do
src:write(tm, self.distIoFrame, self)
end
end
self.distIoFrame = self.distIoFrame+1
Expand Down
41 changes: 2 additions & 39 deletions App/Species/VlasovSpecies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -613,48 +613,11 @@ function VlasovSpecies:advance(tCurr, species, emIn, inIdx, outIdx)
end
end
if self.evolveSources then
for _, s in pairs(self.sources) do
s:advance(tCurr, fIn, species, fRhsOut)
for _, src in pairs(self.sources) do
src:advance(tCurr, fIn, species, fRhsOut)
end
end

-- if self.sourceSteadyState and self.evolveSources then
-- local localEdgeFlux = ffi.new("double[3]")
-- localEdgeFlux[0] = 0.0
-- localEdgeFlux[1] = 0.0
-- localEdgeFlux[2] = 0.0

-- local numConfDims = self.confBasis:ndim()
-- assert(numConfDims==1, "VlasovSpecies: The steady state source is available only for 1X.")
-- local numConfBasis = self.confBasis:numBasis()
-- local lower, upper = Lin.Vec(numConfDims), Lin.Vec(numConfDims)
-- lower[1], upper[1] = -1.0, 1.0
-- local basisUpper = Lin.Vec(numConfBasis)
-- local basisLower = Lin.Vec(numConfBasis)

-- self.confBasis:evalBasis(upper, basisUpper)
-- self.confBasis:evalBasis(lower, basisLower)

-- local flux = self:fluidMoments()[2]
-- local fluxIndexer, fluxItr = flux:genIndexer(), flux:get(1)
-- for idx in flux:localRangeIter() do
-- if idx[1] == self.grid:numCells(1) then
-- flux:fill(fluxIndexer(idx), fluxItr)
-- for k = 1, numConfBasis do
-- localEdgeFlux[0] = localEdgeFlux[0] + fluxItr[k]*basisUpper[k]
-- end
-- elseif idx[1] == 1 then
-- flux:fill(fluxIndexer(idx), fluxItr)
-- for k = 1, numConfBasis do
-- localEdgeFlux[0] = localEdgeFlux[0] - fluxItr[k]*basisLower[k]
-- end
-- end
-- end
-- local globalEdgeFlux = ffi.new("double[3]")
-- Mpi.Allreduce(localEdgeFlux, globalEdgeFlux, 1,
-- Mpi.DOUBLE, Mpi.MAX, self.grid:commSet().comm)
-- local densFactor = globalEdgeFlux[0]/self.sourceSteadyStateLength
-- fRhsOut:accumulate(densFactor, self.fSource)
if self.projSrc and self.evolveSources then
-- add source it to the RHS
-- Barrier over shared communicator before accumulate
Expand Down
3 changes: 3 additions & 0 deletions Regression/gk-neutrals/rt-neutrals-1x2vSOL.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ plasmaApp = Plasma.App {

-- Source parameters.
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperatureElc,
},
Expand Down Expand Up @@ -190,6 +191,7 @@ plasmaApp = Plasma.App {

-- Source Parameters.
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperatureIon,
},
Expand Down Expand Up @@ -264,6 +266,7 @@ plasmaApp = Plasma.App {

-- Source parameters.
source = Vlasov.Source {
type = "Maxwellian",
density = sourceDensityNeut,
temperature = 2.*eV,
},
Expand Down
3 changes: 3 additions & 0 deletions Regression/gk-neutrals/rt-nstx-neut-lowRes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ plasmaApp = Plasma.App {

-- Source parameters
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down Expand Up @@ -262,6 +263,7 @@ plasmaApp = Plasma.App {

-- Source parameters.
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down Expand Up @@ -362,6 +364,7 @@ plasmaApp = Plasma.App {

-- Source parameters.
source = Vlasov.Source {
type = "Maxwellian",
density = sourceDensityNeut,
temperature = 2.*eV,
},
Expand Down
2 changes: 2 additions & 0 deletions Regression/gk-sheath/rt-gk-sheath-GenGeo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ plasmaApp = Plasma.App {
frequencies = {nuElc},
},
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down Expand Up @@ -201,6 +202,7 @@ plasmaApp = Plasma.App {
frequencies = {nuIon},
},
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down
2 changes: 2 additions & 0 deletions Regression/gk-sheath/rt-gk-sheath.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ plasmaApp = Plasma.App {
frequencies = {nuElc},
},
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down Expand Up @@ -184,6 +185,7 @@ plasmaApp = Plasma.App {
frequencies = {nuIon},
},
source = Plasma.Source {
type = "Maxwellian",
density = sourceDensity,
temperature = sourceTemperature,
power = P_src/2,
Expand Down

0 comments on commit 1b5f7ce

Please sign in to comment.