[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contamination of Jacobian using AD in WCNSFV multi-system #29065

Open
GiudGiud opened this issue Nov 13, 2024 · 2 comments
Open

Contamination of Jacobian using AD in WCNSFV multi-system #29065

GiudGiud opened this issue Nov 13, 2024 · 2 comments
Labels
P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.

Comments

@GiudGiud
Copy link
Contributor

Bug Description

Perfect Jacobian achieved using AD for the fully coupled approach become incorrect as soon as we switch to multi-system.
At this point, I am about 70% sure because of AD derivatives being propagated from one system to the next

Steps to Reproduce

Run this with Navier Stokes with my multi-sys branch

mu=1
rho=1
diff=1e-3
advected_interp_method='average'
velocity_interp_method='rc'

[GlobalParams]
  rhie_chow_user_object = 'rc'
  advected_interp_method='average'
  velocity_interp_method='rc'
[]

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

[Mesh]
  [gen]
    type = GeneratedMeshGenerator
    dim = 2
    xmin = 0
    xmax = 10
    ymin = -1
    ymax = 1
    nx = 10
    ny = 5
  []
[]

[Variables]
  [u]
    type = INSFVVelocityVariable
    initial_condition = 1
  []
  [v]
    type = INSFVVelocityVariable
    initial_condition = 1
  []
  [pressure]
    type = INSFVPressureVariable
  []
[]

[Variables]
  [scalar]
    type = INSFVScalarFieldVariable
    solver_sys = "scalar"
  []
[]


[AuxVariables]
  [ax_out]
    type = MooseVariableFVReal
  []
  [ay_out]
    type = MooseVariableFVReal
  []
[]

[AuxKernels]
  [ax_out]
    type = FunctorAux
    functor = ax
    variable = ax_out
    execute_on = timestep_end
  []
  [ay_out]
    type = FunctorAux
    functor = ay
    variable = ay_out
    execute_on = timestep_end
  []
[]


[FVKernels]
  [mass]
    type = INSFVMassAdvection
    variable = pressure
    rho = ${rho}
  []

  [u_advection]
    type = INSFVMomentumAdvection
    variable = u
    rho = ${rho}
    momentum_component = 'x'
  []
  [u_viscosity]
    type = INSFVMomentumDiffusion
    variable = u
    mu = ${mu}
    momentum_component = 'x'
  []
  [u_pressure]
    type = INSFVMomentumPressure
    variable = u
    momentum_component = 'x'
    pressure = pressure
  []

  [v_advection]
    type = INSFVMomentumAdvection
    variable = v
    rho = ${rho}
    momentum_component = 'y'
  []
  [v_viscosity]
    type = INSFVMomentumDiffusion
    variable = v
    mu = ${mu}
    momentum_component = 'y'
  []
  [v_pressure]
    type = INSFVMomentumPressure
    variable = v
    momentum_component = 'y'
    pressure = pressure
  []
[]

[FVBCs]
  [inlet-u]
    type = INSFVInletVelocityBC
    boundary = 'left'
    variable = u
    function = '1'
  []
  [inlet-v]
    type = INSFVInletVelocityBC
    boundary = 'left'
    variable = v
    function = 0
  []
  [walls-u]
    type = INSFVNoSlipWallBC
    boundary = 'top bottom'
    variable = u
    function = 0
  []
  [walls-v]
    type = INSFVNoSlipWallBC
    boundary = 'top bottom'
    variable = v
    function = 0
  []
  [outlet_p]
    type = INSFVOutletPressureBC
    boundary = 'right'
    variable = pressure
    function = 0
  []
[]


[FVKernels]
  [scalar_advection]
    type = INSFVScalarFieldAdvection
    variable = scalar
    velocity_interp_method = ${velocity_interp_method}
    advected_interp_method = ${advected_interp_method}
  []
  [scalar_diffusion]
    type = FVDiffusion
    coeff = ${diff}
    variable = scalar
  []
  [scalar_src]
    type = FVBodyForce
    variable = scalar
    value = 0.1
  []
[]

[FVBCs]
  [inlet_scalar]
    type = FVDirichletBC
    boundary = 'left'
    variable = scalar
    value = 1
  []
[]

[Problem]
  nl_sys_names = "nl0 scalar"
[]

[Executioner]
  type = Steady
  solve_type = 'NEWTON'
  petsc_options = '-snes_test_jacobian'
  petsc_options_iname = '-pc_type -pc_factor_shift_type'
  petsc_options_value = 'lu       NONZERO'
  line_search = 'none'
  nl_rel_tol = 1e-12
[]

[Outputs]
  exodus = true
[]

Impact

Ruins convergence of Newton in multi-system problems due to incorrect Jacobian.

[Optional] Diagnostics

No response

@GiudGiud GiudGiud added T: defect An anomaly, which is anything that deviates from expectations. P: normal A defect affecting operation with a low possibility of significantly affects. labels Nov 13, 2024
@lindsayad
Copy link
Member

I assume you've run -snes_test_jacobian?

@GiudGiud
Copy link
Contributor Author

yes that's in the test input.
at this point I think it s the RC object being re-executed incorrectly

@GiudGiud GiudGiud changed the title Contamination of Jacobian using AD in multi-system Contamination of Jacobian using AD in WCNSFV multi-system Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.
Projects
None yet
Development

No branches or pull requests

2 participants