From 1b5f7ceabe26b4710f6cc380ca32f58eb6aaf0d3 Mon Sep 17 00:00:00 2001 From: kolterb Date: Tue, 20 Apr 2021 15:49:12 -0400 Subject: [PATCH] updated sources to specify type of distribution --- App/Sources/GkSource.lua | 27 +++++++++--- App/Sources/VmSource.lua | 27 +++++++++--- App/Species/GkSpecies.lua | 4 +- App/Species/KineticSpecies.lua | 12 +++--- App/Species/VlasovSpecies.lua | 41 +------------------ .../gk-neutrals/rt-neutrals-1x2vSOL.lua | 3 ++ .../gk-neutrals/rt-nstx-neut-lowRes.lua | 3 ++ Regression/gk-sheath/rt-gk-sheath-GenGeo.lua | 2 + Regression/gk-sheath/rt-gk-sheath.lua | 2 + 9 files changed, 64 insertions(+), 57 deletions(-) diff --git a/App/Sources/GkSource.lua b/App/Sources/GkSource.lua index 448fa4051..fddd8ae2a 100644 --- a/App/Sources/GkSource.lua +++ b/App/Sources/GkSource.lua @@ -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 diff --git a/App/Sources/VmSource.lua b/App/Sources/VmSource.lua index aaf5d8ced..ae8b6dc91 100644 --- a/App/Sources/VmSource.lua +++ b/App/Sources/VmSource.lua @@ -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 diff --git a/App/Species/GkSpecies.lua b/App/Species/GkSpecies.lua index 8028f2154..f201b1fd8 100644 --- a/App/Species/GkSpecies.lua +++ b/App/Species/GkSpecies.lua @@ -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 diff --git a/App/Species/KineticSpecies.lua b/App/Species/KineticSpecies.lua index a6d9842c5..3040d349d 100644 --- a/App/Species/KineticSpecies.lua +++ b/App/Species/KineticSpecies.lua @@ -277,8 +277,8 @@ 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) @@ -286,8 +286,8 @@ function KineticSpecies:setConfGrid(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 @@ -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 diff --git a/App/Species/VlasovSpecies.lua b/App/Species/VlasovSpecies.lua index 2616ef585..1c766867d 100644 --- a/App/Species/VlasovSpecies.lua +++ b/App/Species/VlasovSpecies.lua @@ -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 diff --git a/Regression/gk-neutrals/rt-neutrals-1x2vSOL.lua b/Regression/gk-neutrals/rt-neutrals-1x2vSOL.lua index d5df72d43..5eac7be3d 100644 --- a/Regression/gk-neutrals/rt-neutrals-1x2vSOL.lua +++ b/Regression/gk-neutrals/rt-neutrals-1x2vSOL.lua @@ -126,6 +126,7 @@ plasmaApp = Plasma.App { -- Source parameters. source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperatureElc, }, @@ -190,6 +191,7 @@ plasmaApp = Plasma.App { -- Source Parameters. source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperatureIon, }, @@ -264,6 +266,7 @@ plasmaApp = Plasma.App { -- Source parameters. source = Vlasov.Source { + type = "Maxwellian", density = sourceDensityNeut, temperature = 2.*eV, }, diff --git a/Regression/gk-neutrals/rt-nstx-neut-lowRes.lua b/Regression/gk-neutrals/rt-nstx-neut-lowRes.lua index 821247641..fdc99490d 100644 --- a/Regression/gk-neutrals/rt-nstx-neut-lowRes.lua +++ b/Regression/gk-neutrals/rt-nstx-neut-lowRes.lua @@ -174,6 +174,7 @@ plasmaApp = Plasma.App { -- Source parameters source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2, @@ -262,6 +263,7 @@ plasmaApp = Plasma.App { -- Source parameters. source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2, @@ -362,6 +364,7 @@ plasmaApp = Plasma.App { -- Source parameters. source = Vlasov.Source { + type = "Maxwellian", density = sourceDensityNeut, temperature = 2.*eV, }, diff --git a/Regression/gk-sheath/rt-gk-sheath-GenGeo.lua b/Regression/gk-sheath/rt-gk-sheath-GenGeo.lua index 8869c3f48..61ff5dea3 100644 --- a/Regression/gk-sheath/rt-gk-sheath-GenGeo.lua +++ b/Regression/gk-sheath/rt-gk-sheath-GenGeo.lua @@ -148,6 +148,7 @@ plasmaApp = Plasma.App { frequencies = {nuElc}, }, source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2, @@ -201,6 +202,7 @@ plasmaApp = Plasma.App { frequencies = {nuIon}, }, source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2, diff --git a/Regression/gk-sheath/rt-gk-sheath.lua b/Regression/gk-sheath/rt-gk-sheath.lua index a15f76d4b..69058e01b 100644 --- a/Regression/gk-sheath/rt-gk-sheath.lua +++ b/Regression/gk-sheath/rt-gk-sheath.lua @@ -132,6 +132,7 @@ plasmaApp = Plasma.App { frequencies = {nuElc}, }, source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2, @@ -184,6 +185,7 @@ plasmaApp = Plasma.App { frequencies = {nuIon}, }, source = Plasma.Source { + type = "Maxwellian", density = sourceDensity, temperature = sourceTemperature, power = P_src/2,