From 34d3b4bacd0ee4bee5ebbc0450429599a98b43a8 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Fri, 30 Sep 2022 09:36:03 +0100 Subject: [PATCH 1/3] North Sea: actually use shorter test time --- examples/north_sea/model_config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/north_sea/model_config.py b/examples/north_sea/model_config.py index be5332a09..72aafd780 100644 --- a/examples/north_sea/model_config.py +++ b/examples/north_sea/model_config.py @@ -97,15 +97,15 @@ def construct_solver(spinup=False, store_station_time_series=True, **model_optio coriolis_2d.interpolate(2 * omega * sin(lat * pi / 180.0)) # Setup temporal discretisation - default_start_date = datetime.datetime(2022, 1, 1, tzinfo=sim_tz) - default_end_date = datetime.datetime(2022, 1, 2, tzinfo=sim_tz) + default_start_date = datetime.datetime(2022, 1, 1, 0, 0, tzinfo=sim_tz) + default_end_date = datetime.datetime(2022, 1, 2, 0, 0, tzinfo=sim_tz) start_date = model_options.pop("start_date", default_start_date) end_date = model_options.pop("end_date", default_end_date) dt = 3600.0 t_export = 3600.0 t_end = (end_date - start_date).total_seconds() if os.getenv("THETIS_REGRESSION_TEST") is not None: - t_end = 5 * t_export + end_date = datetime.datetime(2022, 1, 1, 0, 5, tzinfo=sim_tz) # Create solver solver_obj = solver2d.FlowSolver2d(mesh2d, bathymetry_2d) From fff2666b9dc21617b7a8a8d3fd1fb1736aaf0981 Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Fri, 30 Sep 2022 09:36:19 +0100 Subject: [PATCH 2/3] Tohoku: make date-aware --- examples/tohoku_inversion/inverse_problem.py | 3 ++- examples/tohoku_inversion/model_config.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/examples/tohoku_inversion/inverse_problem.py b/examples/tohoku_inversion/inverse_problem.py index b7a297934..5438de733 100644 --- a/examples/tohoku_inversion/inverse_problem.py +++ b/examples/tohoku_inversion/inverse_problem.py @@ -78,7 +78,8 @@ sta_manager.set_model_field(solver_obj.fields.elev_2d) # Define the scaling for the cost function so that J ~ O(1) -J_scalar = Constant(solver_obj.dt / options.simulation_end_time) +t_end = (options.simulation_end_date - options.simulation_initial_date).total_seconds() +J_scalar = Constant(solver_obj.dt / t_end) # Create inversion manager and add controls no_exports = os.getenv("THETIS_REGRESSION_TEST") is not None diff --git a/examples/tohoku_inversion/model_config.py b/examples/tohoku_inversion/model_config.py index 3ed0ada65..632e3edde 100644 --- a/examples/tohoku_inversion/model_config.py +++ b/examples/tohoku_inversion/model_config.py @@ -9,7 +9,8 @@ import scipy.interpolate as si -# Setup UTM zone +# Setup zones +sim_tz = timezone.pytz.timezone("Japan") coord_system = coordsys.UTMCoordinateSystem(utm_zone=54) # Earthquake epicentre in longitude-latitude coordinates @@ -117,12 +118,19 @@ def construct_solver(elev_init, store_station_time_series=True, **model_options) """ mesh2d = elev_init.function_space().mesh() - t_end = 2 * 3600.0 + # Setup temporal discretisation u_mag = Constant(5.0) + default_start_date = datetime.datetime(2011, 3, 11, 14, 46, tzinfo=sim_tz) + default_end_date = datetime.datetime(2011, 3, 11, 16, 46, tzinfo=sim_tz) t_export = 60.0 dt = 60.0 if os.getenv("THETIS_REGRESSION_TEST") is not None: - t_end = 5 * t_export + model_options["simulation_initial_date"] = default_start_date + model_options["simulation_end_date"] = datetime.datetime(2011, 3, 11, 14, 51, tzinfo=sim_tz) + if "simulation_initial_date" not in model_options: + model_options["simulation_initial_date"] = default_start_date + if "simulation_end_date" not in model_options: + model_options["simulation_end_date"] = default_end_date # Bathymetry P1_2d = get_functionspace(mesh2d, "CG", 1) @@ -141,7 +149,6 @@ def construct_solver(elev_init, store_station_time_series=True, **model_options) options.element_family = "dg-dg" options.simulation_export_time = t_export options.fields_to_export = ["elev_2d"] - options.simulation_end_time = t_end options.horizontal_velocity_scale = u_mag options.swe_timestepper_type = "CrankNicolson" if not hasattr(options.swe_timestepper_options, "use_automatic_timestep"): From 1b073425f37bb9ba501a3a3fa8a3471257ddf1ac Mon Sep 17 00:00:00 2001 From: Joe Wallwork Date: Thu, 29 Feb 2024 14:04:00 +0000 Subject: [PATCH 3/3] minutes->hours --- examples/north_sea/model_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/north_sea/model_config.py b/examples/north_sea/model_config.py index 72aafd780..aa59d1e06 100644 --- a/examples/north_sea/model_config.py +++ b/examples/north_sea/model_config.py @@ -105,7 +105,7 @@ def construct_solver(spinup=False, store_station_time_series=True, **model_optio t_export = 3600.0 t_end = (end_date - start_date).total_seconds() if os.getenv("THETIS_REGRESSION_TEST") is not None: - end_date = datetime.datetime(2022, 1, 1, 0, 5, tzinfo=sim_tz) + end_date = datetime.datetime(2022, 1, 1, 5, 0, tzinfo=sim_tz) # Create solver solver_obj = solver2d.FlowSolver2d(mesh2d, bathymetry_2d)