def __init__(self, *args, **kwargs): super(TestFluid, self).__init__(*args, **kwargs) self.rho = 1.0 self.mu = 2.0 self.c_f = 3.0 self.fluid_1 = Fluid(density=self.rho, viscosity=self.mu) self.fluid_2 = Fluid(density=self.rho, viscosity=self.mu, heat_capacity=self.c_f)
def __init__(self, *args, **kwargs): super(TestFractureNetworkThermal, self).__init__(*args, **kwargs) # fluid properties cp_w = 4300.0 rho_w = 1000.0 mu_w = 1E-3 self.fluid = Fluid(density=rho_w, viscosity=mu_w, heat_capacity=cp_w) # reservoir properties k_r = 2.9 cp_r = 1050.0 rho_r = 2700.0 alpha_r = k_r / (rho_r * cp_r) # first network conn_1 = [(0, 1), (1, 2), (1, 3), (2, 4), (3, 4), (4, 5)] L_1 = [100, 500, 500, 500, 500, 100] H_1 = [500, 500, 500, 500, 500, 500] w_1 = [1E-3, 1E-3, 1E-3, 1E-3, 1E-3, 1E-3] self.network_1 = FractureNetworkThermal(conn_1, L_1, H_1, w_1, k_r, alpha_r) # second network conn_2 = [(0, 1), (1, 2), (2, 3), (1, 4), (2, 5), (3, 6), (4, 5), (5, 6), (4, 7), (5, 8), (6, 9), (7, 8), (8, 9), (9, 10)] L_2 = 250 * np.ones(len(conn_2)) L_2[0] = 100 L_2[-1] = 100 H_2 = 500 * np.ones(len(conn_2)) w_2 = 1E-3 * np.ones(len(conn_2)) self.network_2 = FractureNetworkThermal(conn_2, L_2, H_2, w_2, k_r, alpha_r)
def test_read_fluid_json(self): file_path = self.get_file_path('fluid_data.json') fluid_1 = read_fluid_json(file_path) with open(file_path, 'r') as f: data = json.load(f) fluid_2 = Fluid(data['density'], data['viscosity'], data['heat_capacity']) self.assertEqual(fluid_1, fluid_2)
def __init__(self, *args, **kwargs): super(TestFractureNetworkFlow, self).__init__(*args, **kwargs) conn = [(0, 1), (1, 2), (1, 2), (2, 3)] L = [1.0, 1.0, 1.0, 1.0] H = [1.0, 1.0, 1.0, 1.0] w = [1.0, 1.0, 1.0, 1.0] self.fluid = Fluid(density=1.0, viscosity=2.0, heat_capacity=3.0) self.network = FractureNetworkFlow(conn, L, H, w) self.network.fluid = self.fluid P_0 = 0.0 m_inj = 1.0 self.essential_bc = {0: P_0} self.point_sources = {3: -m_inj}
# Operational properties m_inj = 50.0 P_inj = 0.0 # Network properties n_segs = 4 conn = [(0, 1), (1, 2), (1, 2), (2, 3)] L = [100, 500, 500, 100] H = [500, 500, 500, 500] w = [1E-3, 1E-3, 1E-3, 1E-3] n_inj = 0 n_prod = 3 # Create network object fluid = Fluid(density=rho_w, viscosity=mu_w, heat_capacity=None) network = FractureNetworkFlow(conn, L, H, w) # Calculate flow in the network essential_bc = {n_inj: P_inj} point_sources = {n_prod: -m_inj} network.calculate_flow(fluid, essential_bc, point_sources, correct=True) # Generate and plot results flow_fraction = calculate_flow_fraction(network, essential_bc, point_sources) f = plt.figure() plt.hist(flow_fraction, bins=50, normed=True) plt.xlabel('flow fraction (-)') plt.ylabel('probability density (-)')
def read_fluid_json(data): return Fluid(**data)