Skip to content

Commit

Permalink
Add 1D perfect conservation case
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Dec 19, 2024
1 parent f21f9ce commit 0a0aa7d
Show file tree
Hide file tree
Showing 3 changed files with 245 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
L = 30
bulk_u = 0.01
p_ref = 101325.0

A_cp = 976.78
B_cp = 1.0634

advected_interp_method = 'upwind'

[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 1
xmin = 0
xmax = ${L}
nx = 10
[]
[]

[GlobalParams]
rhie_chow_user_object = 'rc'
advected_interp_method = ${advected_interp_method}
velocity_interp_method = 'rc'
[]

[UserObjects]
[rc]
type = INSFVRhieChowInterpolator
u = vel_x
pressure = pressure
[]
[]

[Variables]
[vel_x]
type = INSFVVelocityVariable
initial_condition = ${bulk_u}
two_term_boundary_expansion = false
[]
[pressure]
type = INSFVPressureVariable
initial_condition = ${p_ref}
two_term_boundary_expansion = false
[]
[T]
type = INSFVEnergyVariable
two_term_boundary_expansion = false
initial_condition = 860.
[]
[]

[FVKernels]
[mass]
type = WCNSFVMassAdvection
variable = pressure
rho = 'rho'
[]

[u_advection]
type = INSFVMomentumAdvection
variable = vel_x
rho = 'rho'
momentum_component = 'x'
[]
[u_viscosity]
type = INSFVMomentumDiffusion
variable = vel_x
mu = 'mu'
momentum_component = 'x'
[]
[u_pressure]
type = INSFVMomentumPressure
variable = vel_x
momentum_component = 'x'
pressure = pressure
[]

[temp_conduction]
type = FVDiffusion
coeff = 'k'
variable = T
[]
[temp_advection]
type = INSFVEnergyAdvection
variable = T
[]
[source]
type = FVBodyForce
variable = T
function = source_func
[]
[]

[FVBCs]
[inlet-u]
type = INSFVInletVelocityBC
boundary = 'left'
variable = vel_x
functor = ${bulk_u}
[]
[inlet_T]
type = FVDirichletBC
variable = T
boundary = 'left'
value = 860.
[]

[outlet_p]
type = INSFVOutletPressureBC
boundary = 'right'
variable = pressure
function = ${p_ref}
[]
[]

[FluidProperties]
# [fp]
# # type = TemperaturePressureFunctionFluidProperties
# # cv = 4000
# # k = 0.7
# # rho = 2000
# # mu = 4.5e-3
# type = LeadFluidProperties
# []
[]

[Functions]
[source_func]
type = ParsedFunction
expression = '50000.'
[]
[]

[FunctorMaterials]
[converter_to_regular_T]
type = FunctorADConverter
ad_props_in = 'T'
reg_props_out = 'T_nAD'
[]
# [fluid_props_to_mat_props]
# type = GeneralFunctorFluidProps
# fp = 'fp'
# pressure = ${p_ref}
# T_fluid = 'T'
# speed = 1
# porosity = 1
# characteristic_length = 1
# output_properties = 'cp'
# outputs = 'all'
# []
[ins_fv]
type = INSFVEnthalpyFunctorMaterial
temperature = 'T'
rho = 'rho'
cp = 'cp'

assume_constant_cp = false
h = 'h'
# fp = 'fp'
# pressure = 'pressure'
[]

[rho]
type = ADParsedFunctorMaterial
property_name = 'rho'
expression = '2000'
[]
[mu]
type = ADParsedFunctorMaterial
property_name = 'mu'
expression = '4.5e-3'
[]
[k]
type = ADParsedFunctorMaterial
property_name = 'k'
expression = '0.7'
[]
[h]
type = ADParsedFunctorMaterial
property_name = 'h'
functor_names = 'T ${A_cp} ${B_cp}'
functor_symbols = 'T A_cp B_cp'
expression = 'A_cp * T + B_cp * T * T / 2'
[]
[cp]
type = ADParsedFunctorMaterial
property_name = 'cp'
functor_names = 'T ${A_cp} ${B_cp}'
functor_symbols = 'T A_cp B_cp'
expression = 'A_cp+B_cp*T'
[]
[]

[Executioner]
type = Steady
solve_type = 'NEWTON'
petsc_options_iname = '-pc_type -pc_factor_shift_type'
petsc_options_value = 'lu NONZERO'

nl_abs_tol = 1e-9
nl_max_its = 50
line_search = 'none'

automatic_scaling = true
off_diagonals_in_auto_scaling = true
[]

[Postprocessors]
[H_in]
type = VolumetricFlowRate
vel_x = 'vel_x'
advected_quantity = 'rho_h'
boundary = 'left'
[]
[H_out]
type = VolumetricFlowRate
vel_x = 'vel_x'
advected_quantity = 'rho_h'
boundary = 'right'
[]
[Q]
type = FunctionElementIntegral
function = 'source_func'
execute_on = 'initial'
[]
[balance_in_percent]
type = ParsedPostprocessor
expression = '(H_out + H_in - Q) / H_in * 100'
pp_names = 'H_in H_out Q'
[]
[]

[Outputs]
csv = true
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time,H_in,H_out,Q,balance_in_percent
0,0,0,1500000,0
1,-24665522.4,26165522.540111,1500000,-5.6804577370916e-07
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
requirement = 'The system shall be able to compute the specific enthalpy and the enthalpy with a non constant specific heat.'
recover = false
[]
[validation_nonconstant_cp]
type = 'CSVDiff'
input = 1d_test_cpT.i
csvdiff = 1d_test_cpT_out.csv
requirement = 'The system shall be able to compute the specific enthalpy and the enthalpy with a non constant specific heat, and show near perfect energy conservation.'
recover = false
[]

[exceptions]
requirement = "The system shall throw an error if"
Expand Down

0 comments on commit 0a0aa7d

Please sign in to comment.