diff --git a/examples/north_sea/model_config.py b/examples/north_sea/model_config.py index 106eaa1ee..07408c39b 100644 --- a/examples/north_sea/model_config.py +++ b/examples/north_sea/model_config.py @@ -97,8 +97,8 @@ def construct_solver(mesh2d, spinup=False, store_station_time_series=True, **mod 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 diff --git a/examples/tohoku_inversion/inverse_problem.py b/examples/tohoku_inversion/inverse_problem.py index 4115f22fa..617090e81 100644 --- a/examples/tohoku_inversion/inverse_problem.py +++ b/examples/tohoku_inversion/inverse_problem.py @@ -75,7 +75,8 @@ ) # Define the scaling for the cost function so that dJ/dm ~ O(1) # TODO: Update scaling to depend on number of DOFs in the problem -cost_function_scaling = domain_constant(10000000 * solver_obj.dt / options.simulation_end_time, mesh2d) +time_span = (options.simulation_end_date - options.simulation_initial_date).total_seconds() +cost_function_scaling = domain_constant(10000000 * solver_obj.dt / time_span, mesh2d) sta_manager.cost_function_scaling = cost_function_scaling sta_manager.load_scalar_observation_data( observation_data_dir, diff --git a/examples/tohoku_inversion/model_config.py b/examples/tohoku_inversion/model_config.py index 51b84e06b..f939749b8 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(bathymetry_2d, elev_init, store_station_time_series=True, * """ 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 bathymetry_2d.interpolate(bathymetry_2d - elev_init) @@ -134,7 +142,6 @@ def construct_solver(bathymetry_2d, elev_init, store_station_time_series=True, * 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"): diff --git a/thetis/solver2d.py b/thetis/solver2d.py index ef5a31b82..79a34dfe6 100644 --- a/thetis/solver2d.py +++ b/thetis/solver2d.py @@ -1090,7 +1090,7 @@ def create_iterator(self, update_forcings=None, export_func=None, adj_timesteppe init_date = self.options.simulation_initial_date end_date = self.options.simulation_end_date if (init_date is not None and end_date is not None): - now = init_date + datetime.timedelta(initial_simulation_time) + now = init_date + datetime.timedelta(seconds=initial_simulation_time) assert end_date > now, f'Simulation end date must be greater than initial time {now}' print_output( f'Running simulation\n'