diff --git a/doc/world_builder_declarations.schema.json b/doc/world_builder_declarations.schema.json index ad7ec82e4..d850b429a 100644 --- a/doc/world_builder_declarations.schema.json +++ b/doc/world_builder_declarations.schema.json @@ -7744,7 +7744,7 @@ "description": "The velocity with which the ridge is moving through time, and how long the ridge has been moving. First value is the velocity, second is the time. Default is [0 cm/yr, 0 yr]", "oneOf": [ { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" }, @@ -7761,7 +7761,7 @@ "uniqueItems": false, "description": "", "items": { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" } @@ -8599,7 +8599,7 @@ "description": "The velocity with which the ridge is moving through time, and how long the ridge has been moving. First value is the velocity, second is the time. Default is [0 cm/yr, 0 yr]", "oneOf": [ { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" }, @@ -8616,7 +8616,7 @@ "uniqueItems": false, "description": "", "items": { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" } @@ -9524,7 +9524,7 @@ "description": "The velocity with which the ridge is moving through time, and how long the ridge has been moving. First value is the velocity, second is the time. Default is [0 cm/yr, 0 yr]", "oneOf": [ { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" }, @@ -9541,7 +9541,7 @@ "uniqueItems": false, "description": "", "items": { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" } @@ -10379,7 +10379,7 @@ "description": "The velocity with which the ridge is moving through time, and how long the ridge has been moving. First value is the velocity, second is the time. Default is [0 cm/yr, 0 yr]", "oneOf": [ { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" }, @@ -10396,7 +10396,7 @@ "uniqueItems": false, "description": "", "items": { - "default value": -1.0, + "default value": 0.05, "type": "number", "description": "" } diff --git a/doc/world_builder_declarations_closed.md b/doc/world_builder_declarations_closed.md index baae334c8..0e2cf7640 100644 --- a/doc/world_builder_declarations_closed.md +++ b/doc/world_builder_declarations_closed.md @@ -11332,7 +11332,7 @@ ::::::::::::{dropdown} /features/items/oneOf/6/segments/items/temperature models/items/oneOf/3/subducting velocity/oneOf/1 :name: closed_features_items_oneOf_6_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -11356,7 +11356,7 @@ ::::::::::{dropdown} /features/items/oneOf/6/segments/items/temperature models/items/oneOf/3/subducting velocity/oneOf/2/items/items :name: closed_features_items_oneOf_6_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: @@ -12532,7 +12532,7 @@ ::::::::::::::{dropdown} /features/items/oneOf/6/temperature models/items/oneOf/3/subducting velocity/oneOf/1 :name: closed_features_items_oneOf_6_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::::: @@ -12556,7 +12556,7 @@ ::::::::::::{dropdown} /features/items/oneOf/6/temperature models/items/oneOf/3/subducting velocity/oneOf/2/items/items :name: closed_features_items_oneOf_6_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -13836,7 +13836,7 @@ ::::::::::{dropdown} /features/items/oneOf/6/sections/items/segments/items/temperature models/items/oneOf/3/subducting velocity/oneOf/1 :name: closed_features_items_oneOf_6_sections_items_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: @@ -13860,7 +13860,7 @@ ::::::::{dropdown} /features/items/oneOf/6/sections/items/segments/items/temperature models/items/oneOf/3/subducting velocity/oneOf/2/items/items :name: closed_features_items_oneOf_6_sections_items_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::: @@ -15036,7 +15036,7 @@ ::::::::::::{dropdown} /features/items/oneOf/6/sections/items/temperature models/items/oneOf/3/subducting velocity/oneOf/1 :name: closed_features_items_oneOf_6_sections_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -15060,7 +15060,7 @@ ::::::::::{dropdown} /features/items/oneOf/6/sections/items/temperature models/items/oneOf/3/subducting velocity/oneOf/2/items/items :name: closed_features_items_oneOf_6_sections_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: diff --git a/doc/world_builder_declarations_open.md b/doc/world_builder_declarations_open.md index ff2baa691..163c83c27 100644 --- a/doc/world_builder_declarations_open.md +++ b/doc/world_builder_declarations_open.md @@ -12774,7 +12774,7 @@ :open: :name: open_features_items_oneOf_6_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -12801,7 +12801,7 @@ :open: :name: open_features_items_oneOf_6_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: @@ -14115,7 +14115,7 @@ :open: :name: open_features_items_oneOf_6_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::::: @@ -14142,7 +14142,7 @@ :open: :name: open_features_items_oneOf_6_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -15575,7 +15575,7 @@ :open: :name: open_features_items_oneOf_6_sections_items_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: @@ -15602,7 +15602,7 @@ :open: :name: open_features_items_oneOf_6_sections_items_segments_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::: @@ -16916,7 +16916,7 @@ :open: :name: open_features_items_oneOf_6_sections_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_1 -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::::: @@ -16943,7 +16943,7 @@ :open: :name: open_features_items_oneOf_6_sections_items_temperature-models_items_oneOf_3_subducting-velocity_oneOf_2_items_items -- **default value**:-1.0 +- **default value**:0.05 - **type**:number - **description**: :::::::::: diff --git a/source/world_builder/features/subducting_plate_models/temperature/mass_conserving.cc b/source/world_builder/features/subducting_plate_models/temperature/mass_conserving.cc index fe15020f6..638849286 100644 --- a/source/world_builder/features/subducting_plate_models/temperature/mass_conserving.cc +++ b/source/world_builder/features/subducting_plate_models/temperature/mass_conserving.cc @@ -121,7 +121,7 @@ namespace WorldBuilder prm.declare_entry("plate velocity", Types::OneOf(Types::Double(0.05),Types::Array(Types::ValueAtPoints(0.05, std::numeric_limits::max()))), "The velocity with which the plate subducts in meters per year. Default is 5 cm/yr"); - prm.declare_entry("subducting velocity", Types::OneOf(Types::Double(-1), Types::Array(Types::Array(Types::Double(-1), 1), 1)), + prm.declare_entry("subducting velocity", Types::OneOf(Types::Double(0.05), Types::Array(Types::Array(Types::Double(0.05), 1), 1)), "The velocity with which the ridge is moving through time, and how long the ridge " "has been moving. First value is the velocity, second is the time. Default is [0 cm/yr, 0 yr]"); @@ -289,6 +289,8 @@ namespace WorldBuilder const AdditionalParameters &additional_parameters) const { + const double seconds_in_year = 60.0 * 60.0 * 24.0 * 365.25; // sec/y + const double distance_from_plane = distance_from_planes.distance_from_plane; if (distance_from_plane <= max_depth && distance_from_plane >= min_depth) @@ -317,7 +319,6 @@ namespace WorldBuilder std::vector slab_ages = calculate_effective_trench_and_plate_ages(ridge_parameters, distance_along_plane); - const double seconds_in_year = 60.0 * 60.0 * 24.0 * 365.25; // sec/y const double spreading_velocity = ridge_parameters[0] * seconds_in_year; // m/yr double subducting_velocity = ridge_parameters[2] * seconds_in_year; // m/yr @@ -358,7 +359,7 @@ namespace WorldBuilder } // Plate age increases with distance along the slab in the mantle - double effective_plate_age = slab_ages[1]; + double effective_plate_age_sec = slab_ages[1] * seconds_in_year; // Need adiabatic temperature at position of grid point const double background_temperature = adiabatic_heating ? potential_mantle_temperature * @@ -452,7 +453,7 @@ namespace WorldBuilder // Also taper the initial heat content and effective plate age initial_heat_content = initial_heat_content * std::erfc(1.5*taper_con*theta); - effective_plate_age = effective_plate_age * std::erfc(1.5*taper_con*theta); + effective_plate_age_sec = effective_plate_age_sec * std::erfc(1.5*taper_con*theta); } else @@ -495,14 +496,14 @@ namespace WorldBuilder exp((subducting_velocity_UI * max_depth / 2.0 / thermal_diffusivity - std::sqrt(subducting_velocity_UI * subducting_velocity_UI * max_depth * max_depth / 4.0 / thermal_diffusivity / thermal_diffusivity + double(2*i + 1) * double(2*i + 1) * Consts::PI * Consts::PI)) * - subducting_velocity_UI * effective_plate_age / max_depth); + subducting_velocity_UI * effective_plate_age_sec / max_depth); bottom_heat_content -= temp_heat_content; } } else { bottom_heat_content = 2 * thermal_conductivity * (min_temperature - potential_mantle_temperature) * - std::sqrt(effective_plate_age /(thermal_diffusivity * Consts::PI)); + std::sqrt(effective_plate_age_sec /(thermal_diffusivity * Consts::PI)); } // 4. The difference in heat content goes into the temperature above where Tmin occurs. @@ -533,7 +534,7 @@ namespace WorldBuilder for (int i = 0; i < 2 * spline_n_points + 1; ++i) { const double i_adjusted_distance = (i * interval_spline_distance - 1.0) * max_depth; - const double i_temperature = get_temperature_analytic(top_heat_content, min_temperature, background_temperature, temperature_, spreading_velocity, effective_plate_age, i_adjusted_distance); + const double i_temperature = get_temperature_analytic(top_heat_content, min_temperature, background_temperature, temperature_, spreading_velocity, effective_plate_age_sec, i_adjusted_distance); i_temperatures[i] = i_temperature; } @@ -545,7 +546,7 @@ namespace WorldBuilder else { // Call the analytic solution to compute the temperature - temperature = get_temperature_analytic(top_heat_content, min_temperature, background_temperature, temperature_, spreading_velocity, effective_plate_age, adjusted_distance); + temperature = get_temperature_analytic(top_heat_content, min_temperature, background_temperature, temperature_, spreading_velocity, effective_plate_age_sec, adjusted_distance); } } else @@ -569,7 +570,7 @@ namespace WorldBuilder const double background_temperature, const double temperature_, const double subducting_velocity, - const double effective_plate_age, + const double effective_plate_age_sec, const double adjusted_distance) const { const double seconds_in_year = 60.0 * 60.0 * 24.0 * 365.25; // sec/y @@ -613,7 +614,7 @@ namespace WorldBuilder std::exp((((subducting_velocity_UI * max_depth)/(2 * thermal_diffusivity)) - std::sqrt(((subducting_velocity_UI*subducting_velocity_UI*max_depth*max_depth) / (4*thermal_diffusivity*thermal_diffusivity)) + double(i) * double(i) * Consts::PI * Consts::PI)) * - ((subducting_velocity_UI * effective_plate_age) / max_depth))); + ((subducting_velocity_UI * effective_plate_age_sec) / max_depth))); } } else @@ -624,7 +625,7 @@ namespace WorldBuilder else { temperature = background_temperature + (min_temperature - background_temperature) * - std::erfc(adjusted_distance / (2 * std::sqrt(thermal_diffusivity * effective_plate_age))); + std::erfc(adjusted_distance / (2 * std::sqrt(thermal_diffusivity * effective_plate_age_sec))); } } diff --git a/source/world_builder/utilities.cc b/source/world_builder/utilities.cc index 2c3e2a155..3c6b98873 100644 --- a/source/world_builder/utilities.cc +++ b/source/world_builder/utilities.cc @@ -1485,18 +1485,25 @@ namespace WorldBuilder WBAssert(ridge_parameters.size() == 4, "Internal error: ridge_parameters have the wrong size: " << ridge_parameters.size() << " instead of 4."); const double seconds_in_year = 60.0 * 60.0 * 24.0 * 365.25; // sec/y const double spreading_velocity = ridge_parameters[0] * seconds_in_year; // m/yr - double subducting_velocity = ridge_parameters[2] * seconds_in_year; // m/yr + const double distance_ridge = ridge_parameters[1]; - if (subducting_velocity <= 0) + // Use value of spreading velocity is the subducting velocity is unset + double subducting_velocity; + if (isnan(ridge_parameters[2])) subducting_velocity = spreading_velocity; - - const double age_at_trench = ridge_parameters[1] / spreading_velocity; // m/(m/y) = yr - const double plate_age_sec = age_at_trench * seconds_in_year; // y --> seconds + else + subducting_velocity = ridge_parameters[2] * seconds_in_year; // m/yr + WBAssertThrow(subducting_velocity >= 0, "The subducting velocity is less than 0. " + "Subducting velocity: " << subducting_velocity); // Plate age increases with distance along the slab in the mantle - double effective_plate_age = plate_age_sec + (distance_along_plane / subducting_velocity) * seconds_in_year; // m/(m/y) = y(seconds_in_year) - WBAssertThrow(effective_plate_age >= 0, "The age of the subducting plate is less than or equal to 0. " - "Effective plate age: " << effective_plate_age); + double effective_plate_age = (distance_ridge + distance_along_plane) / spreading_velocity; // m/(m/y) = yr + + // Age of trench when the query point was at the trench + const double age_at_trench = effective_plate_age - distance_along_plane / subducting_velocity; // m/(m/y) = yr + WBAssertThrow(age_at_trench >= 0, "The age of trench at subducting initiation is less than 0. " + "Age at trench: " << age_at_trench); + std::vector result; result.push_back(age_at_trench); result.push_back(effective_plate_age); diff --git a/tests/gwb-dat/cartesian_multiridge.wb b/tests/gwb-dat/cartesian_multiridge.wb index cf9b98258..6fe067c78 100644 --- a/tests/gwb-dat/cartesian_multiridge.wb +++ b/tests/gwb-dat/cartesian_multiridge.wb @@ -22,7 +22,7 @@ "segments":[{"length":200e3,"thickness":[300e3],"top truncation":[-100e3],"angle":[90]}, {"length":460e3,"thickness":[300e3],"top truncation":[-300e3],"angle":[90]}], "temperature models":[{"model":"mass conserving", "density":3300, "thermal conductivity":3.3, - "adiabatic heating":true,"plate velocity":0.125, + "adiabatic heating":true,"plate velocity":0.125, "subducting velocity": 0.125, "ridge coordinates":[[[1500e3,1500e3],[1500e3,2250e3]],[[1000e3,2250e3],[1000e3,3000e3]]], "coupling depth":100e3, "taper distance":100e3, "min distance slab top":-300e3, "max distance slab top":300e3}], diff --git a/tests/gwb-dat/cartesian_young_slab_mass_conserving.wb b/tests/gwb-dat/cartesian_young_slab_mass_conserving.wb index ad3ef4402..d70f609e6 100644 --- a/tests/gwb-dat/cartesian_young_slab_mass_conserving.wb +++ b/tests/gwb-dat/cartesian_young_slab_mass_conserving.wb @@ -15,7 +15,7 @@ "temperature models":[ {"model":"mass conserving", "density":3300, "thermal conductivity":3.3,"adiabatic heating":true, - "plate velocity":0.04, + "plate velocity":0.04, "subducting velocity": 0.04, "ridge coordinates":[[[2900e3,-100e3],[2900e3,100e3]]], "coupling depth":120e3, "forearc cooling factor":10.0, diff --git a/tests/gwb-dat/mass_conserving_slab_with_variable_spreading.wb b/tests/gwb-dat/mass_conserving_slab_with_variable_spreading.wb index 970e2e9a1..06dc502c1 100644 --- a/tests/gwb-dat/mass_conserving_slab_with_variable_spreading.wb +++ b/tests/gwb-dat/mass_conserving_slab_with_variable_spreading.wb @@ -138,6 +138,7 @@ "thermal conductivity": 3.3, "adiabatic heating": true, "plate velocity": [ [1,[[0.000005, 0.05]]] ], + "subducting velocity": [[0.000005, 0.05]], "ridge coordinates": [ [ [ diff --git a/tests/gwb-dat/slab_temperature_trench_advance.dat b/tests/gwb-dat/slab_temperature_trench_advance.dat new file mode 100644 index 000000000..184a1d331 --- /dev/null +++ b/tests/gwb-dat/slab_temperature_trench_advance.dat @@ -0,0 +1,18 @@ +# 2 profiles across a slab, one at 500 km depth +# and one at 200 km depth +# Now define parameters: +# dim = 2 +# compositions = 0 +# x z d T +8000e3 0 500e3 +8050e3 0 500e3 +8100e3 0 500e3 +8150e3 0 500e3 +8200e3 0 500e3 +8300e3 0 500e3 +7800e3 0 200e3 +7850e3 0 200e3 +7900e3 0 200e3 +7950e3 0 200e3 +8000e3 0 200e3 +8200e3 0 200e3 \ No newline at end of file diff --git a/tests/gwb-dat/slab_temperature_trench_retreat.dat b/tests/gwb-dat/slab_temperature_trench_retreat.dat new file mode 100644 index 000000000..184a1d331 --- /dev/null +++ b/tests/gwb-dat/slab_temperature_trench_retreat.dat @@ -0,0 +1,18 @@ +# 2 profiles across a slab, one at 500 km depth +# and one at 200 km depth +# Now define parameters: +# dim = 2 +# compositions = 0 +# x z d T +8000e3 0 500e3 +8050e3 0 500e3 +8100e3 0 500e3 +8150e3 0 500e3 +8200e3 0 500e3 +8300e3 0 500e3 +7800e3 0 200e3 +7850e3 0 200e3 +7900e3 0 200e3 +7950e3 0 200e3 +8000e3 0 200e3 +8200e3 0 200e3 \ No newline at end of file diff --git a/tests/gwb-dat/slab_temperature_trench_retreat.wb b/tests/gwb-dat/slab_temperature_trench_retreat.wb new file mode 100644 index 000000000..a7d747c98 --- /dev/null +++ b/tests/gwb-dat/slab_temperature_trench_retreat.wb @@ -0,0 +1,163 @@ +{ + "version":"0.6", + "coordinate system":{"model":"cartesian"}, + "gravity model":{"model":"uniform", "magnitude":10}, + "cross section":[[0,0],[10000e3,0]],"surface temperature":273, "force surface temperature":true, + "potential mantle temperature":1673, "thermal expansion coefficient":3.1e-5, + "specific heat":1000, "thermal diffusivity":1.0e-6, + "features": + [ + { + "model": "oceanic plate", + "name": "sp plate", + "max depth": 150000.0, + "min depth": -100000.0, + "coordinates": [ + [ + 0.0, + -1000.0 + ], + [ + 0.0, + 1000.0 + ], + [ + 7500000.0, + 1000.0 + ], + [ + 7500000.0, + -1000.0 + ] + ], + "temperature models": [ + { + "model": "plate model", + "min depth": -10000.0, + "max depth": 150000.0, + "spreading velocity": 0.05, + "ridge coordinates": [ + [ + [ + 0, + -1000.0 + ], + [ + 0, + 1000.0 + ] + ] + ] + } + ], + "composition models": [ + { + "model": "uniform", + "min depth": -10000.0, + "max depth": 7500.0, + "compositions": [ + 0 + ] + }, + { + "model": "uniform", + "min depth": 7500.0, + "max depth": 35200.0, + "compositions": [ + 1 + ] + } + ] + }, + { + "model": "subducting plate", + "name": "initial slab", + "coordinates": [ + [ + 7500000.0, + -1000.0 + ], + [ + 7500000.0, + 1000.0 + ] + ], + "dip point": [ + 40000000.0, + 0.0 + ], + "segments": [ + { + "length": 1000000.0, + "thickness": [ + 300000.0 + ], + "top truncation": [ + -100000.0 + ], + "angle": [ + 0, + 80 + ], + "composition models": [ + { + "model": "uniform", + "compositions": [ + 0 + ], + "max distance slab top": 7500.0 + }, + { + "model": "uniform", + "compositions": [ + 1 + ], + "min distance slab top": 7500.0, + "max distance slab top": 35200.0 + } + ] + }, + { + "length": 300000.0, + "thickness": [ + 300000.0 + ], + "top truncation": [ + -100000.0 + ], + "angle": [ + 80, + 80 + ] + } + ], + "temperature models": [ + { + "model": "mass conserving", + "density": 3300, + "thermal conductivity": 3.3, + "adiabatic heating": true, + "plate velocity": 0.05, + "subducting velocity": 0.05, + "ridge coordinates": [ + [ + [ + 0, + -1000.0 + ], + [ + 0, + 1000.0 + ] + ] + ], + "coupling depth": 50000.0, + "taper distance": 100000.0, + "min distance slab top": -100000.0, + "max distance slab top": 150000.0, + "reference model name": "plate model" + } + ] + } + ] +} diff --git a/tests/gwb-dat/spherical_mc_slab_and_half_space_plate_model.wb b/tests/gwb-dat/spherical_mc_slab_and_half_space_plate_model.wb index 76ae2b827..87c6c3604 100644 --- a/tests/gwb-dat/spherical_mc_slab_and_half_space_plate_model.wb +++ b/tests/gwb-dat/spherical_mc_slab_and_half_space_plate_model.wb @@ -21,7 +21,7 @@ {"length":700e3, "thickness":[300e3], "top truncation":[-300e3], "angle":[50,50]}, {"length":300e3, "thickness":[300e3], "top truncation":[-300e3], "angle":[50,10]}], "temperature models":[{"model":"mass conserving", "density":3300, "thermal conductivity":3.3, - "adiabatic heating":true, "plate velocity":0.03, "ridge coordinates": [[[45,-5],[45,5]]], + "adiabatic heating":true, "plate velocity":0.03, "subducting velocity":0.03, "ridge coordinates": [[[45,-5],[45,5]]], "coupling depth":100e3, "taper distance":100e3, "min distance slab top":-300e3, "max distance slab top":300e3}] } diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__calculate_effective_trench_and_plate_ages.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__calculate_effective_trench_and_plate_ages.txt new file mode 100644 index 000000000..766860dca --- /dev/null +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__calculate_effective_trench_and_plate_ages.txt @@ -0,0 +1,8 @@ +TITLE + + +[0] = 6.96779e+07 +[1] = 1.36348e+08 +[2] = 1.03013e+08 +[3] = 1.36348e+08 + diff --git a/tests/unit_tests/unit_test_world_builder.cc b/tests/unit_tests/unit_test_world_builder.cc index 9db97b789..a0eafbdf9 100644 --- a/tests/unit_tests/unit_test_world_builder.cc +++ b/tests/unit_tests/unit_test_world_builder.cc @@ -7743,3 +7743,38 @@ TEST_CASE("WorldBuilder Utilities function: calculate_ridge_distance_and_spreadi ApprovalTests::Approvals::verifyAll("TITLE", approval_tests); } + +TEST_CASE("WorldBuilder Utilities function: calculate_effective_trench_and_plate_ages") +{ + std::vector approval_tests; + + // test 1: trivial case, spreading velocity = subducting velocity and no ridge migration + const std::vector ridge_parameters_1 = {4.75299e-10, 1.04512e+06, 4.75299e-10, 0.0}; // m/s, m, m/s, s + const double distance_along_plane_1 = 1000e3; + std::vector result1 = Utilities::calculate_effective_trench_and_plate_ages(ridge_parameters_1, distance_along_plane_1); + + approval_tests.emplace_back(result1[0]); // age at trench + approval_tests.emplace_back(result1[1]); // effective plate age + + // test 2: 2 * spreading velocity = subducting velocity and no ridge migration, trench retreating + std::vector ridge_parameters_2 = {4.75299e-10, 1.04512e+06, 9.50598e-10, 0.0}; // m/s, m, m/s, s + const double distance_along_plane_2 = 1000e3; + std::vector result2 = Utilities::calculate_effective_trench_and_plate_ages(ridge_parameters_2, distance_along_plane_2); + + approval_tests.emplace_back(result2[0]); // age at trench + approval_tests.emplace_back(result2[1]); // effective plate age + + ApprovalTests::Approvals::verifyAll("TITLE", approval_tests); + + // test 3: negative subducting velocity triggers error + std::vector ridge_parameters_3 = {4.75299e-10, 1.04512e+06, -9.50598e-10, 0.0}; // m/s, m, m/s, s + const double distance_along_plane_3 = 1000e3; + CHECK_THROWS_WITH(Utilities::calculate_effective_trench_and_plate_ages(ridge_parameters_3, distance_along_plane_3), + Contains("The subducting velocity is less than 0.")); + + // test 4: subducting velocity is too small, causing negative trench age at subducting initiation + std::vector ridge_parameters_4 = {4.75299e-10, 1.04512e+06, 9.50598e-11, 0.0}; // m/s, m, m/s, s + const double distance_along_plane_4 = 1000e3; + CHECK_THROWS_WITH(Utilities::calculate_effective_trench_and_plate_ages(ridge_parameters_4, distance_along_plane_4), + Contains("The age of trench at subducting initiation is less than 0. ")); +}