@@ -2725,18 +2725,12 @@ subroutine EqDerivatives_assemble_jacobian(self, solver, solution)
27252725 type (EqSolver), intent (in ) :: solver
27262726 type (EqSolution), intent (inout ) :: solution
27272727
2728- if (solver% smooth_truncation) then
2729- call EqDerivatives_assemble_effective_jacobian(self, solver, solution)
2730- else
2731- call solver% assemble_matrix(solution)
2732- self% J = solution% G(:self% m, :self% m)
2733- end if
2728+ call EqDerivatives_assemble_effective_jacobian(self, solver, solution)
27342729 end subroutine
27352730
27362731 subroutine EqDerivatives_assemble_effective_jacobian (self , solver , solution )
2737- ! Assemble the derivative-only Jacobian for smooth problems using the
2738- ! converged effective residual linearization rather than the forward
2739- ! Newton update matrix.
2732+ ! Assemble the derivative-only Jacobian from the converged effective
2733+ ! residual rather than reusing the forward Newton update matrix.
27402734
27412735 ! Arguments
27422736 class(EqDerivatives), intent (inout ) :: self
@@ -2752,6 +2746,7 @@ subroutine EqDerivatives_assemble_effective_jacobian(self, solver, solution)
27522746 real (dp) :: ln_n
27532747 real (dp) :: ln_threshold
27542748 real (dp) :: n_delta
2749+ real (dp) :: hsu_delta
27552750 real (dp) :: tmp(solver% num_gas)
27562751 real (dp) :: mu_g(solver% num_gas)
27572752 real (dp) :: ln_nj_eff(solver% num_gas)
@@ -2811,6 +2806,14 @@ subroutine EqDerivatives_assemble_effective_jacobian(self, solver, solution)
28112806 nj_eval = solution% nj
28122807 nj_eval(:ng) = nj_eff_g
28132808 n_delta = n - sum (nj_eff_g)
2809+ hsu_delta = 0.0d0
2810+ if (const_h) then
2811+ hsu_delta = solution% constraints% state1/ solution% T - &
2812+ dot_product (nj_eval, solution% thermo% enthalpy)
2813+ else if (const_u) then
2814+ hsu_delta = solution% constraints% state1/ solution% T - &
2815+ dot_product (nj_eval, solution% thermo% energy)
2816+ end if
28142817
28152818 self% J = 0.0d0
28162819 r = 0
@@ -2913,9 +2916,9 @@ subroutine EqDerivatives_assemble_effective_jacobian(self, solver, solution)
29132916
29142917 c = c + 1
29152918 if (const_p) then
2916- self% J(r, c) = dot_product (nj_eval, cp) + dot_product (tmp, h_g)
2919+ self% J(r, c) = dot_product (nj_eval, cp) + dot_product (tmp, h_g) + hsu_delta
29172920 else
2918- self% J(r, c) = dot_product (nj_eval, cv) + dot_product (tmp, u_g)
2921+ self% J(r, c) = dot_product (nj_eval, cv) + dot_product (tmp, u_g) + hsu_delta
29192922 if (const_s) then
29202923 self% J(r, c) = self% J(r, c) - dot_product (nj_eff_g, u_g)
29212924 end if
@@ -3125,9 +3128,6 @@ subroutine EqDerivatives_assemble_Rx(self, solver, solution)
31253128 end if
31263129 else
31273130 self% Rx(r, c) = 0.0d0
3128- if (.not. const_p) then
3129- self% Rx(r, c) = self% Rx(r, c) - sum (tmp)/ T
3130- end if
31313131 end if
31323132
31333133 ! dR/dx3...n (x3...n: element amounts)
0 commit comments