Skip to content

Commit

Permalink
Add 1D case showing:
Browse files Browse the repository at this point in the history
- balance to 1e-8
- error to T_out in analytical solution down to 5e-6
  • Loading branch information
GiudGiud committed Dec 20, 2024
1 parent 66eaa5d commit 4d8a100
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
L = 30
bulk_u = 0.01
p_ref = 101325.0
T_in = 860
q_source = 50000

A_cp = 976.78
B_cp = 1.0634
rho = 2000

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 = ${T_in}
[]
[]

[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 = ${T_in}
[]

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

[Functions]
[source_func]
type = ParsedFunction
expression = '${q_source}'
[]
[]

[FunctorMaterials]
[converter_to_regular_T]
type = FunctorADConverter
ad_props_in = 'T'
reg_props_out = 'T_nAD'
[]
[ins_fv]
type = INSFVEnthalpyFunctorMaterial
temperature = 'T'
rho = 'rho'
cp = 'cp'

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

[rho]
type = ADParsedFunctorMaterial
property_name = 'rho'
expression = '${rho}'
[]
[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'
[]

[T_out]
type = SideAverageValue
variable = T
boundary = 'right'
[]
[T_analytical]
type = Receiver
default = ${fparse (-A_cp+sqrt(A_cp^2-2*B_cp*(-q_source/rho/bulk_u*L-A_cp*T_in-B_cp/2*T_in*T_in)))/B_cp}
[]
[error_T]
type = ParsedPostprocessor
expression = 'T_out - T_analytical'
pp_names = 'T_out T_analytical'
[]
[]

[Outputs]
csv = true
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time,H_in,H_out,Q,T_analytical,T_out,balance_in_percent,error_T
0,0,0,1500000,899.2226858156,0,0,0
1,-24665522.4,26165522.540111,1500000,899.2226858156,899.22268943977,-5.6804577370916e-07,3.6241718817109e-06
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 4d8a100

Please sign in to comment.