def simple_validation(): """ Validation on Ivar setup""" # Grid gb, box, mesh_args = create_grid() # Injection phases and time configuration start_time = -1e2 * pp.YEAR end_time = 15 * pp.YEAR phase_limits = [start_time, 0, 10 * 3600, end_time] rates = [0, 75, 20] injection_protocol = InjectionRateProtocol.create_protocol(phase_limits, rates) phase_time_steps = [-start_time, 2.0, 2 / 3 * pp.HOUR] time_params = TimeStepProtocol.create_protocol(phase_limits, phase_time_steps) # Newton newton_params = NewtonParameters(convergence_tol=1e-6, max_iterations=15,) # Model parameters biot_params = BiotParameters( # BaseParameters length_scale=15, scalar_scale=1e9, base=Path("/home/haakonervik/mastersproject-data"), head="validation_example", time=time_params.start_time, time_step=time_params.initial_time_step, end_time=time_params.end_time, gravity=True, rock=IvarGranite(), # GeometryParameters shearzone_names=["f1", "f2", "f3"], box=box, mesh_args=mesh_args, # MechanicsParameters dilation_angle=np.radians(5.0), newton_options=newton_params.dict(), # FlowParameters well_cells=_tag_ivar_well_cells, injection_protocol=injection_protocol, frac_transmissivity=5.17e-3, # Gives a0=2e-3, which are Ivar's values. # BiotParameters alpha=0.8, ) setup = ISCBiotContactMechanics(biot_params) setup.gb = gb time_machine = TimeMachinePhasesConstantDt(setup, newton_params, time_params) time_machine.run_simulation() return time_machine
def prepare_params( length_scale, scalar_scale, ) -> Tuple[BiotParameters, NewtonParameters, TimeStepProtocol]: """ Validation on the ISC grid""" injection_protocol, time_params = isc_dt_and_injection_protocol() newton_params = NewtonParameters( convergence_tol=1e-6, max_iterations=200, ) sz = 10 # path = Path(__file__).parent / "isc_simulation/200830/box-test/t1-gravity" root = Path.home() path = root / "mastersproject-data/results/200830/5f-50kc/t1" biot_params = BiotParameters( # BaseParameters length_scale=length_scale, scalar_scale=scalar_scale, # base=Path("/home/haakonervik/mastersproject-data"), # head="validation_example", folder_name=path, time_step=time_params.initial_time_step, end_time=time_params.end_time, gravity=True, # GeometryParameters shearzone_names=["S1_1", "S1_2", "S1_3", "S3_1", "S3_2"], mesh_args={ "mesh_size_frac": sz, "mesh_size_min": 0.1 * sz, "mesh_size_bound": 3 * sz, }, bounding_box=None, # MechanicsParameters dilation_angle=np.radians(3), newton_options=newton_params.dict(), # FlowParameters well_cells=shearzone_injection_cell, injection_protocol=injection_protocol, frac_transmissivity=[5e-8, 1e-9, 5e-10, 3.7e-7, 1e-9], # Initial transmissivites for # ["S1_1", "S1_2", "S1_3", "S3_1", "S3_2"]: # [5e-8, 1e-9, 5e-10, 3.7e-7, 1e-9] ) return biot_params, newton_params, time_params
def test_aperture_of_fracture_intersection(): here = Path(__file__).parent / "simulations" options = { "folder_name": here, "shearzone_names": ["S1_1", "S3_1"], "bounding_box": { "xmin": 0, "ymin": 0, "zmin": 0, "xmax": 6, "ymax": 6, "zmax": 6, }, "source_scalar_borehole_shearzone": None, } params = BiotParameters(**options) setup = ISCBiotContactMechanics(params) setup.gb = structured_grid_2_intx_fracs() setup._prepare_grid() setup.set_biot_parameters() setup.initial_biot_condition() # Set an aperture on the mortar grids gb = setup.gb s11 = setup.grids_by_name("S1_1")[0] s31 = setup.grids_by_name("S3_1")[0] de11 = gb.edge_props((s11, setup._nd_grid())) de31 = gb.edge_props((s31, setup._nd_grid())) mg11, mg31 = de11["mortar_grid"], de31["mortar_grid"] sgn11, sgn31 = mg11.sign_of_mortar_sides(3), mg31.sign_of_mortar_sides(3) u11 = sgn11 * np.ones_like(de11[pp.STATE][pp.ITERATE]["mortar_u"]) u31 = sgn31 * np.ones_like(de31[pp.STATE][pp.ITERATE]["mortar_u"]) de11[pp.STATE][pp.ITERATE]["mortar_u"] = u11 * 5 de31[pp.STATE][pp.ITERATE]["mortar_u"] = u31 * 2 # Get mechanical aperture in the intersection ix = gb.grids_of_dimension(1)[0] ap = setup.mechanical_aperture(ix, scaled=False, from_iterate=True) assert np.all( ap == 5 * 2), ("Disregarding shear, we expected the max jump to be 2 * 5, " "where 5 is each side of the u11 displacement")
def params(tmpdir_factory): inj, dt = create_protocols() newton_params = NewtonParameters(convergence_tol=1e-6, max_iterations=10,) path = tmpdir_factory.mktemp("results") biot_params = BiotParameters( # BaseParameters length_scale=0.04, scalar_scale=1e8, folder_name=path, time_step=dt.initial_time_step, end_time=dt.end_time, # GeometryParameters shearzone_names=["S1_1", "S1_2", "S1_3", "S3_1"], # MechanicsParameters newton_options=newton_params, # FlowParameters frac_transmissivity=1e-8, ) return biot_params, newton_params, dt
def assemble_isc_matrix(values): """ Optimize the isc setup values = (length_scale, log10(scalar_scale)) if return_both is set, return both estimates for condition number. """ length_scale, log_scalar_scale = values # Component values of input scalar_scale = np.float_power(10, log_scalar_scale) _sz = 40 mesh_args = { "mesh_size_frac": _sz, "mesh_size_min": 0.2 * _sz, "mesh_size_bound": 3 * _sz, } here = ( Path(__file__).parent / f"results/test_optimal_scaling/ls{length_scale:.2e}_ss{scalar_scale:.2e}" ) params = BiotParameters( # Base length_scale=length_scale, scalar_scale=scalar_scale, folder_name=here, time_step=1 * 60, # 1 minute rock=GrimselGranodiorite(), # Geometry shearzone_names=["S1_2", "S3_1"], mesh_args=mesh_args, # Mechanics stress=stress_tensor(), dilation_angle=(np.pi / 180) * 5, # Flow frac_transmissivity=[1e-9, 3.7e-7], ) setup = ISCBiotContactMechanics(params) setup.prepare_simulation() A, _ = setup.assembler.assemble_matrix_rhs() return A
biot_params = BiotParameters( # BaseParameters length_scale=length_scale, scalar_scale=scalar_scale, base=base, head=head, time_step=time_params.initial_time_step, end_time=time_params.end_time, rock=GrimselGranodiorite( PERMEABILITY=k, ), # low k: 5e-21 -- high k: 2 * 5e-21 gravity=False, # GeometryParameters shearzone_names=[ "S1_1", "S1_2", "S1_3", "S3_1", ], # "S3_2"], # ["S1_2", "S3_1"], fraczone_bounding_box=box, # MechanicsParameters dilation_angle=np.radians(3), newton_options=newton_params.dict(), # FlowParameters source_scalar_borehole_shearzone={ "shearzone": "S1_3", "borehole": "INJ2", }, well_cells=shearzone_injection_cell, tunnel_equilibrium_time=tunnel_equilibration_time, injection_protocol=injection_protocol, frac_transmissivity=[ 5e-8, 1e-9, 8.3e-11, # Pre-stimulation T during HS1, observed in S1.3-INJ2. 3.7e-7, # 1e-9, ], # Initial transmissivites for # ["S1_1", "S1_2", "S1_3", "S3_1", "S3_2"]: # [5e-8, 1e-9, 5e-10, 3.7e-7, 1e-9] # Note background hydraulic conductivity: 1e-14 m/s # near_injection_transmissivity=8.3e-11, # near_injection_t_radius=3, )
def prepare_params( length_scale, scalar_scale, ) -> Tuple[BiotParameters, NewtonParameters, TimeStepProtocol]: """ Hydro shearing experiment HS1 HS1 targeted S1.3 through INJ2 at 39.75 - 40.75 m. """ tunnel_equilibration_time = 30 * pp.YEAR injection_protocol, time_params = _hs1_protocols_optimal_scaling() newton_params = NewtonParameters( convergence_tol=1e-6, max_iterations=300, ) biot_params = BiotParameters( # BaseParameters length_scale=length_scale, scalar_scale=scalar_scale, use_temp_path=True, # Use a temporary directory for storing mesh time_step=time_params.initial_time_step, end_time=time_params.end_time, rock=GrimselGranodiorite( PERMEABILITY=5e-21, # low k: 5e-21 -- high k: 2 * 5e-21 ), gravity=False, # GeometryParameters shearzone_names=[ "S1_1", "S1_2", "S1_3", "S3_1", # TODO: This is the wrong S3 shear zone. ], # "S3_2"], # ["S1_2", "S3_1"], fraczone_bounding_box={ "xmin": -1, "ymin": 80, "zmin": -5, # -5, # Extended frac zone boundary box test "xmax": 86, # +10, "ymax": 151, # +5, "zmax": 41, # +5, }, # MechanicsParameters dilation_angle=np.radians(3), # FlowParameters source_scalar_borehole_shearzone={ "shearzone": "S1_3", "borehole": "INJ2", }, well_cells=shearzone_injection_cell, tunnel_equilibrium_time= tunnel_equilibration_time, # TODO: Think about initial conditions for scaling injection_protocol=injection_protocol, frac_transmissivity=[ 5e-8, 1e-9, 8.3e-11, # Pre-stimulation T during HS1, observed in S1.3-INJ2. 3.7e-7, # 1e-9, ], # Initial transmissivites for # ["S1_1", "S1_2", "S1_3", "S3_1", "S3_2"]: # [5e-8, 1e-9, 5e-10, 3.7e-7, 1e-9] # Note background hydraulic conductivity: 1e-14 m/s # near_injection_transmissivity=8.3e-11, # near_injection_t_radius=3, ) return biot_params, newton_params, time_params