Chi-Tech
test/modules/LinearBoltzmannSolvers/Transport_Adjoint/Adjoint2D_3c_response.lua
-- 2D Transport test with point source Multigroup Adjoint Response
-- SDM: PWLD
-- Test: Inner-product=3.30607e-06
num_procs = 4
--############################################### Check num_procs
if (check_num_procs==nil and chi_number_of_processes ~= num_procs) then
chiLog(LOG_0ERROR,"Incorrect amount of processors. " ..
"Expected "..tostring(num_procs)..
". Pass check_num_procs=false to override if possible.")
os.exit(false)
end
--############################################### Setup mesh
nodes={}
N=60
L=5.0
ds=L/N
xmin=0.0
for i=0,N do
nodes[i+1] = xmin + i*ds
end
meshgen1 = chi_mesh.OrthogonalMeshGenerator.Create({ node_sets = {nodes,nodes} })
----############################################### Set Material IDs
NewRPP = chi_mesh.RPPLogicalVolume.Create
vol0 = NewRPP({infx=true, infy=true, infz=true})
vol1 = NewRPP({ymin=0.0,ymax=0.8*L,infx=true,infz=true})
----############################################### Set Material IDs
vol0b = NewRPP({xmin=-0.166666+2.5,xmax=0.166666+2.5,infy=true,infz=true})
vol1b = NewRPP({xmin=-1+2.5,xmax=1+2.5,ymin=0.9*L,ymax=L,infz=true})
--############################################### Add materials
materials = {}
materials[1] = chiPhysicsAddMaterial("Test Material");
materials[2] = chiPhysicsAddMaterial("Test Material2");
chiPhysicsMaterialAddProperty(materials[1],TRANSPORT_XSECTIONS)
chiPhysicsMaterialAddProperty(materials[2],TRANSPORT_XSECTIONS)
chiPhysicsMaterialAddProperty(materials[1],ISOTROPIC_MG_SOURCE)
chiPhysicsMaterialAddProperty(materials[2],ISOTROPIC_MG_SOURCE)
num_groups = 10
TRANSPORT_XSECTIONS,
SIMPLEXS1,num_groups,0.01,0.01)
TRANSPORT_XSECTIONS,
SIMPLEXS1,num_groups,0.1*20,0.8)
src={}
for g=1,num_groups do
src[g] = 0.0
end
src[1] = 0.0
chiPhysicsMaterialSetProperty(materials[1],ISOTROPIC_MG_SOURCE,FROM_ARRAY,src)
src[1] = 0.0
chiPhysicsMaterialSetProperty(materials[2],ISOTROPIC_MG_SOURCE,FROM_ARRAY,src)
src[1] = 1.0
--############################################### Setup Physics
pquad0 = chiCreateProductQuadrature(GAUSS_LEGENDRE_CHEBYSHEV,12, 2)
lbs_block =
{
num_groups = num_groups,
groupsets =
{
{
groups_from_to = {0, num_groups-1},
angular_quadrature_handle = pquad0,
inner_linear_method = "gmres",
l_abs_tol = 1.0e-6,
l_max_its = 500,
gmres_restart_interval = 100,
},
}
}
lbs_options =
{
scattering_order = 1,
}
--############################################### Initialize and Execute Solver
phys1 = lbs.DiscreteOrdinatesAdjointSolver.Create(lbs_block)
lbs.SetOptions(phys1, lbs_options)
--############################################### Add point source
chiLBSAddPointSource(phys1, 1.25 - 0.5*ds, 1.5*ds, 0.0, src)
ss_solver = lbs.SteadyStateSolver.Create({lbs_solver_handle = phys1})
--chiSolverExecute(ss_solver)
chiLBSReadFluxMoments(phys1, "Adjoint2D_3b_adjoint")
chiLog(LOG_0,string.format("Inner-product=%.5e", value))
--############################################### Get field functions
ff_m0 = chiGetFieldFunctionHandleByName("phi_g000_m00")
ff_m1 = chiGetFieldFunctionHandleByName("phi_g000_m01")
ff_m2 = chiGetFieldFunctionHandleByName("phi_g000_m02")
--############################################### Slice plot
--############################################### Volume integrations
--############################################### Exports
if master_export == nil then
chiExportMultiFieldFunctionToVTK({ff_m0, ff_m1, ff_m2},"ZPhi_LBAdjointResponse")
end
--############################################### Cleanup
if (chi_location_id == 0) then
os.execute("rm Adjoint2D_3b_adjoint*.data")
end
virtual void Execute()
void chiLBSAddPointSource(int SolverIndex, double Location_x, double Location_y, double Location_z, table Strength)
void chiLog(int LogType, char LogMsg)
MaterialHandle chiPhysicsAddMaterial(char Name)
void chiPhysicsMaterialAddProperty(int MaterialHandle, int PropertyIndex)
void chiPhysicsMaterialSetProperty(int MaterialHandle, int PropertyIndex, int OperationIndex, varying Information)
Returns chiCreateProductQuadrature(int QuadratureType, varying values)
void chiOptimizeAngularQuadratureForPolarSymmetry(in handle, double normalization)
void chiVolumeMesherSetProperty(int PropertyIndex, varying PropertyValue)
void chiMPIBarrier()
void chiSolverExecute(int solver_handle)
void chiSolverInitialize(int solver_handle)
Definition: lua_functions.c:92
void chiLBSReadFluxMoments(int SolverIndex, string file_base, bool single_file_flag)
handle chiGetFieldFunctionHandleByName(string FFname)
void chiExportMultiFieldFunctionToVTK(table listFFHandles, char BaseName)
void chiAdjointSolverComputeInnerProduct()
void Set(VecDbl &x, const double &val)