From 683d6202439c73387705d6582227a3e2e5bddcb2 Mon Sep 17 00:00:00 2001 From: Archith Iyer Date: Fri, 8 Nov 2024 14:50:46 -0500 Subject: [PATCH] fix issues with first merge --- src/common/m_variables_conversion.fpp | 4 ++-- src/simulation/m_cbc.fpp | 2 +- src/simulation/m_checker.fpp | 16 ++++++---------- src/simulation/m_riemann_solvers.fpp | 6 +++--- src/simulation/m_start_up.fpp | 2 +- toolchain/mfc/run/input.py | 11 +++++++++-- toolchain/mfc/test/case.py | 8 ++++++++ toolchain/mfc/test/test.py | 2 +- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/common/m_variables_conversion.fpp b/src/common/m_variables_conversion.fpp index 7aab9e8ab..67b91be5c 100644 --- a/src/common/m_variables_conversion.fpp +++ b/src/common/m_variables_conversion.fpp @@ -1424,9 +1424,9 @@ contains if (chemistry) then if (avg_state == 1 .and. abs(c_c) > Tolerance) then - c = sqrt(c_c - (gamma - 1.0._wp)*(vel_sum - H)) + c = sqrt(c_c - (gamma - 1.0_wp)*(vel_sum - H)) else - c = sqrt((1.0._wp + 1.0._wp/gamma)*pres/rho) + c = sqrt((1.0_wp + 1.0_wp/gamma)*pres/rho) end if else if (alt_soundspeed) then diff --git a/src/simulation/m_cbc.fpp b/src/simulation/m_cbc.fpp index c0b24ae8b..139bd0dd8 100644 --- a/src/simulation/m_cbc.fpp +++ b/src/simulation/m_cbc.fpp @@ -805,7 +805,7 @@ contains end do - E = gamma*pres + pi_inf + 5e-1*rho*vel_K_sum + E = gamma*pres + pi_inf + 5e-1_wp*rho*vel_K_sum H = (E + pres)/rho ! Compute mixture sound speed diff --git a/src/simulation/m_checker.fpp b/src/simulation/m_checker.fpp index c14cd6350..683eff39b 100644 --- a/src/simulation/m_checker.fpp +++ b/src/simulation/m_checker.fpp @@ -64,18 +64,14 @@ contains @:PROHIBIT(p + 1 < min(1, p)*num_stcls_min*weno_order, & "For 3D simulation, p must be greater than or equal to (num_stcls_min*weno_order - 1), whose value is "//trim(numStr)) @:PROHIBIT(weno_order /= 1 .and. f_is_default(weno_eps), & - "weno_order != 1, but weno_eps is not set. A typical value of weno_eps is 1e-6") - @:PROHIBIT(weno_eps <= 0d0, "weno_eps must be positive. A typical value of weno_eps is 1e-6") - @:PROHIBIT(wenoz .and. weno_order == 7 .and. f_is_default(wenoz_q), & - "wenoz is used at 7th order, but wenoz_q is not set. It should be either 2, 3, or 4") - @:PROHIBIT(wenoz .and. weno_order == 7 .and. .not. (f_approx_equal(wenoz_q, 2._wp) .or. f_approx_equal(wenoz_q, 3._wp) .or. f_approx_equal(wenoz_q, 4d0)), & - "wenoz_q must be either 2, 3, or 4") - @:PROHIBIT(teno .and. f_is_default(teno_CT), "teno is used, but teno_CT is not set. A typical value of teno_CT is 1e-6") - @:PROHIBIT(teno .and. teno_CT <= 0._wp, "teno_CT must be positive. A typical value of teno_CT is 1e-6") + "weno_order != 1, but weno_eps is not set. A typical value of weno_eps is 1e-6_wp") + @:PROHIBIT(weno_eps <= 0._wp, "weno_eps must be positive. A typical value of weno_eps is 1e-6_wp") + @:PROHIBIT(teno .and. f_is_default(teno_CT), "teno is used, but teno_CT is not set. A typical value of teno_CT is 1e-6_wp") + @:PROHIBIT(teno .and. teno_CT <= 0._wp, "teno_CT must be positive. A typical value of teno_CT is 1e-6_wp") @:PROHIBIT(count([mapped_weno, wenoz, teno]) >= 2, "Only one of mapped_weno, wenoz, or teno can be set to true") @:PROHIBIT(weno_order == 1 .and. mapped_weno) @:PROHIBIT(weno_order == 1 .and. wenoz) - @:PROHIBIT((weno_order == 1 .or. weno_order == 3) .and. teno) + @:PROHIBIT(weno_order /= 5 .and. teno) @:PROHIBIT(weno_order /= 5 .and. mp_weno) @:PROHIBIT(model_eqns == 1 .and. weno_avg) end subroutine s_check_inputs_weno @@ -295,4 +291,4 @@ contains @:PROHIBIT(integral_wrt .and. (.not. bubbles)) end subroutine s_check_inputs_misc -end module m_checker +end module m_checker \ No newline at end of file diff --git a/src/simulation/m_riemann_solvers.fpp b/src/simulation/m_riemann_solvers.fpp index 0c2358e03..ee597435d 100644 --- a/src/simulation/m_riemann_solvers.fpp +++ b/src/simulation/m_riemann_solvers.fpp @@ -2258,10 +2258,10 @@ contains @:compute_average_state() call s_compute_speed_of_sound(pres_L, rho_L, gamma_L, pi_inf_L, H_L, alpha_L, & - vel_L_rms, 0_wp, c_L) + vel_L_rms, 0._wp, c_L) call s_compute_speed_of_sound(pres_R, rho_R, gamma_R, pi_inf_R, H_R, alpha_R, & - vel_R_rms, 0_wp, c_R) + vel_R_rms, 0._wp, c_R) !> The computation of c_avg does not require all the variables, and therefore the non '_avg' ! variables are placeholders to call the subroutine. @@ -4416,4 +4416,4 @@ contains end subroutine s_finalize_riemann_solvers_module -end module m_riemann_solvers +end module m_riemann_solvers \ No newline at end of file diff --git a/src/simulation/m_start_up.fpp b/src/simulation/m_start_up.fpp index 75d31a110..0aba8f5b8 100644 --- a/src/simulation/m_start_up.fpp +++ b/src/simulation/m_start_up.fpp @@ -1110,7 +1110,7 @@ contains if (t_step == 0) dt_init = dt - if (dt < 1e-3*dt_init .and. cfl_adap_dt .and. proc_rank == 0) then + if (dt < 1e-3_wp*dt_init .and. cfl_adap_dt .and. proc_rank == 0) then print*, "Delta t = ", dt call s_mpi_abort("Delta t has become too small") end if diff --git a/toolchain/mfc/run/input.py b/toolchain/mfc/run/input.py index 91e65864b..90787737c 100644 --- a/toolchain/mfc/run/input.py +++ b/toolchain/mfc/run/input.py @@ -5,7 +5,7 @@ from ..printer import cons from .. import common, build -from ..state import ARGS +from ..state import ARGS, ARG from ..case import Case @dataclasses.dataclass(init=False) @@ -69,17 +69,24 @@ def generate_fpp(self, target) -> None: # (Thermo)Chemistry source file modules_dir = os.path.join(target.get_staging_dirpath(self), "modules", target.name) common.create_directory(modules_dir) + + # Determine the real type based on the single precision flag + real_type = 'real(sp)' if ARG('single') else 'real(dp)' + + # Write the generated Fortran code to the m_thermochem.f90 file with the chosen precision common.file_write( os.path.join(modules_dir, "m_thermochem.f90"), pyro.codegen.fortran90.gen_thermochem_code( self.get_cantera_solution(), - module_name="m_thermochem" + module_name="m_thermochem", + real_type=real_type ), True ) cons.unindent() + # Generate case.fpp & [target.name].inp def generate(self, target) -> None: self.generate_inp(target) diff --git a/toolchain/mfc/test/case.py b/toolchain/mfc/test/case.py index 9c4fec309..bdc603953 100644 --- a/toolchain/mfc/test/case.py +++ b/toolchain/mfc/test/case.py @@ -216,11 +216,19 @@ def create_directory(self): def __str__(self) -> str: return f"tests/[bold magenta]{self.get_uuid()}[/bold magenta]: {self.trace}" + def to_input_file(self) -> input.MFCInputFile: + return input.MFCInputFile( + os.path.basename(self.get_filepath()), + self.get_dirpath(), + self.get_parameters()) + def compute_tolerance(self) -> float: single = ARG("single") if self.params.get("hypoelasticity", 'F') == 'T': tol = 1e-7 + elif self.params.get("weno_order") == 7: + tol = 1e-9 elif any(self.params.get(key, 'F') == 'T' for key in ['relax', 'ib', 'qbmm', 'bubbles']): tol = 1e-10 elif self.params.get("low_Mach", 'F') == 1 or self.params.get("low_Mach", 'F') == 2: diff --git a/toolchain/mfc/test/test.py b/toolchain/mfc/test/test.py index 5264507e9..18c266aae 100644 --- a/toolchain/mfc/test/test.py +++ b/toolchain/mfc/test/test.py @@ -233,7 +233,7 @@ def handle_case(case: TestCase, devices: typing.Set[int]): try: _handle_case(case, devices) nPASS += 1 - except Exception as exc: + except MFCException as exc: if nAttempts < max_attempts: continue nFAIL += 1