def set_rock_and_fluid(self): """ Set rock and fluid properties to granite and water. """ self.rock = pp.Granite() self.rock.FRICTION_COEFFICIENT = 0.5 self.fluid = pp.Water() self.rock.PERMEABILITY = 1e-16
def test_granite(self): R = pp.Granite() self.assertEqual(R.PERMEABILITY, 1e-8 * pp.DARCY) self.assertEqual(R.POROSITY, 0.01) self.assertEqual(R.YOUNG_MODULUS, 40 * pp.GIGA * pp.PASCAL) self.assertEqual(R.POISSON_RATIO, 0.2) self.assertEqual(R.DENSITY, 2700 * pp.KILOGRAM / pp.METER**3) self.assertTrue(np.allclose(R.LAMBDA, 11111111111.1111112)) self.assertTrue(np.allclose(R.MU, 16666666666.6666667))
def __init__(self, pb): pb["theta_ref"] = pb["temperature_at_depth"] pb["water"] = pp.Water(pb["theta_ref"]) pb["rock"] = pp.Granite(pb["theta_ref"]) # create the computational grid gb = create_grid(pb) # Darcy problem self.assign_data(gb, pb, FlowData, "problem") pb["file_name"] = "hydraulic_head" flow = pp.EllipticModel(gb, **pb) # transport problem self.assign_data(gb, pb, TransportData, "transport_data") pb["file_name"] = "temperature" transport = TransportSolver(gb, **pb) darcy_and_transport.DarcyAndTransport.__init__(self, flow, transport)
def assign_data(gb): # First we define the rock matrix_rock = pp.Granite() matrix_rock.MU = 20 * pp.GIGA * pp.PASCAL matrix_rock.LAMBDA = 20 * pp.GIGA * pp.PASCAL # We define the variable aperture_change which will be used to update the aperture # at each time step gb.add_node_props(['aperture_change']) for g, d in gb: d['aperture_change'] = np.zeros(g.num_cells) if g.dim == 3: d['rock'] = matrix_rock d['flow_data'] = MatrixDomain(g, d) d['mech_data'] = MechDomain(g, d) d['slip_data'] = pp.FrictionSlipDataAssigner(g, d) else: # We define an injection in the first fracture if d['node_number'] == 1: d['flow_data'] = InjectionDomain(g, d) else: d['flow_data'] = FractureDomain(g, d)
def set_parameters(self, g, data_node, mg, data_edge): """ Set the parameters for the simulation. The stress is given in GPa. """ # Define the finite volume sub grid s_t = pp.fvutils.SubcellTopology(g) # Rock parameters rock = pp.Granite() lam = rock.LAMBDA * np.ones(g.num_cells) / self.pressure_scale mu = rock.MU * np.ones(g.num_cells) / self.pressure_scale k = pp.FourthOrderTensor(g.dim, mu, lam) F = self._friction_coefficient(g, mg, data_edge, s_t) # Define boundary regions east = g.face_centers[0] > np.max(g.nodes[0]) - 1e-9 west = g.face_centers[0] < np.min(g.nodes[0]) + 1e-9 north = g.face_centers[1] > np.max(g.nodes[1]) - 1e-9 south = g.face_centers[1] < np.min(g.nodes[1]) + 1e-9 top = g.face_centers[2] > np.max(g.nodes[2]) - 1e-9 bot = g.face_centers[2] < np.min(g.nodes[2]) + 1e-9 top_hf = top[s_t.fno_unique] bot_hf = bot[s_t.fno_unique] # define boundary condition bc = pp.BoundaryConditionVectorial(g) bc.is_dir[0, east] = True # Rolling bc.is_dir[0, west] = True # Rolling bc.is_dir[1, north] = True # Rolling bc.is_dir[1, south] = True # Rolling bc.is_dir[:, bot] = True # Dirichlet bc.is_neu[bc.is_dir + bc.is_rob] = False # extract boundary condition to subcells bc = pp.fvutils.boundary_to_sub_boundary(bc, s_t) # Give boundary condition values A = g.face_areas[s_t.fno_unique][top_hf] / 3 #* pp.length_scale**g.dim u_bc = np.zeros((g.dim, s_t.num_subfno_unique)) u_bc[2, top_hf] = -4.5 * pp.MEGA * pp.PASCAL / self.pressure_scale * A # Find the continuity points eta = 1 / 3 eta_vec = eta * np.ones(s_t.num_subfno_unique) cont_pnt = g.face_centers[:g.dim, s_t.fno_unique] + eta_vec * ( g.nodes[:g.dim, s_t.nno_unique] - g.face_centers[:g.dim, s_t.fno_unique]) # collect parameters in dictionary key = 'mech' key_m = 'mech' data_node = pp.initialize_data( g, data_node, key, { 'bc': bc, 'bc_values': u_bc.ravel('F'), 'source': 0, 'fourth_order_tensor': k, 'mpsa_eta': eta_vec, 'cont_pnt': cont_pnt, 'rock': rock, }) pp.initialize_data( mg, data_edge, key_m, { 'friction_coeff': F, 'c': 100 * pp.GIGA * pp.PASCAL / self.pressure_scale }) # Define discretization # Solve linear elasticity with mpsa mpsa = pp.Mpsa(key) data_node[pp.PRIMARY_VARIABLES] = {'u': {'cells': g.dim}} data_node[pp.DISCRETIZATION] = {'u': {'mpsa': mpsa}} # Add a Robin condition to the mortar grid contact = pp.numerics.interface_laws.elliptic_interface_laws.RobinContact( key_m, mpsa) data_edge[pp.PRIMARY_VARIABLES] = {'lam': {'cells': g.dim}} data_edge[pp.COUPLING_DISCRETIZATION] = { 'robin_disc': { g: ('u', 'mpsa'), g: ('u', 'mpsa'), (g, g): ('lam', contact), } } return key, key_m
if __name__ == "__main__": file_geo = "Algeroyna.csv" aperture = pp.MILLIMETER data = {"aperture": aperture, "kf": aperture ** 2 / 12} folder = "upscaling" upscaling(file_geo, data, folder, dfn=True) file_geo = "Algeroyna.csv" folder = "solution" theta_ref = 30. * pp.CELSIUS fluid = pp.Water(theta_ref) rock = pp.Granite(theta_ref) aperture = 2 * pp.MILLIMETER # select the permeability depending on the selected test case data = { "aperture": aperture, "kf": aperture ** 2 / 12, "km": 1e7 * rock.PERMEABILITY, "porosity_f": 0.85, "dt": 1e6 * pp.SECOND, "t_max": 1e7 * pp.SECOND, "fluid": fluid, "rock": rock, }
def set_parameters(self, g, data_node, mg, data_edge): """ Set the parameters for the simulation. The stress is given in GPa. """ # Define the finite volume sub grid s_t = pp.fvutils.SubcellTopology(g) # Rock parameters rock = pp.Granite() lam = rock.LAMBDA * np.ones(g.num_cells) / self.pressure_scale mu = rock.MU * np.ones(g.num_cells) / self.pressure_scale F = self._friction_coefficient(g, mg, data_edge, s_t) k = pp.FourthOrderTensor(g.dim, mu, lam) # Define boundary regions top = g.face_centers[g.dim - 1] > np.max(g.nodes[1]) - 1e-9 bot = g.face_centers[g.dim - 1] < np.min(g.nodes[1]) + 1e-9 top_hf = top[s_t.fno_unique] bot_hf = bot[s_t.fno_unique] # Define boundary condition on sub_faces bc = pp.BoundaryConditionVectorial(g, top + bot, 'dir') bc = pp.fvutils.boundary_to_sub_boundary(bc, s_t) # Set the boundary values u_bc = np.zeros((g.dim, s_t.num_subfno_unique)) u_bc[1, top_hf] = -0.002 u_bc[0, top_hf] = 0.005 # Find the continuity points eta = 1 / 3 eta_vec = eta * np.ones(s_t.num_subfno_unique) cont_pnt = g.face_centers[:g.dim, s_t.fno_unique] + eta_vec * ( g.nodes[:g.dim, s_t.nno_unique] - g.face_centers[:g.dim, s_t.fno_unique]) # collect parameters in dictionary key = 'mech' key_m = 'mech' data_node = pp.initialize_data( g, data_node, key, { 'bc': bc, 'bc_values': u_bc.ravel('F'), 'source': 0, 'fourth_order_tensor': k, 'mpsa_eta': eta_vec, 'cont_pnt': cont_pnt, 'rock': rock, }) pp.initialize_data(mg, data_edge, key_m, { 'friction_coeff': F, 'c': 100 }) # Define discretization # For the 2D domain we solve linear elasticity with mpsa. mpsa = pp.Mpsa(key) data_node[pp.PRIMARY_VARIABLES] = {'u': {'cells': g.dim}} data_node[pp.DISCRETIZATION] = {'u': {'mpsa': mpsa}} # And define a Robin condition on the mortar grid contact = pp.numerics.interface_laws.elliptic_interface_laws.RobinContact( key_m, mpsa) data_edge[pp.PRIMARY_VARIABLES] = {'lam': {'cells': g.dim}} data_edge[pp.COUPLING_DISCRETIZATION] = { 'robin_disc': { g: ('u', 'mpsa'), g: ('u', 'mpsa'), (g, g): ('lam', contact), } } return key, key_m