def set_states(state, depths):
    state.context[:] = gas_context
    state.p[:] = Ptop
    state.T[:] = Tporous
    state.S[:] = [1, 0]
    state.C[:] = [[1.0, 0.0], [0.0, 1.0]]


def set_variable_initial_bc_values():
    set_states(simulation.node_states(), Topz - simulation.vertices()[:, 2])
    set_states(simulation.cell_states(), Topz - simulation.compute_cell_centers()[:, 2])
    set_FreeFlow_state(simulation.node_states())
    set_Dirichlet_state(simulation.dirichlet_node_states())


master_print("set initial and BC")
set_variable_initial_bc_values()

# set linear solver properties
newton = Newton(simulation, 1e-7, 15, LinearSolver(1e-6, 50))

context = SimulationContext()
context.abort_on_ksp_failure = False
context.dump_system_on_ksp_failure = False
context.abort_on_newton_failure = False

timestep = TimeStepManager(
    initial_timestep=100.0,
    minimum_timestep=1e-3,
    maximum_timestep=10.0 * year,
    increase_factor=1.2,
Esempio n. 2
0
 def setter(tick):
     if tick.latest_timestep is not None and tick.latest_timestep > dt:
         mpi.master_print(
             f"Changing timestep from {tick.latest_timestep} to {dt}")
         tsmger.current_step = dt
Esempio n. 3
0
shape = nx, ny, nz = 2, 2, 1  # discretization

simulation = ComPASS.load_eos("water2ph")
ComPASS.set_output_directory_and_logfile(__file__)

grid = ComPASS.Grid(shape)

simulation.init(
    mesh=grid,
    cell_permeability=1,
    cell_porosity=0.5,
    cell_thermal_conductivity=1,
)

mpi.master_print("\nNode families\n")

node_family = simulation.NumNodebyProc()

print(f"Family offsets on proc {mpi.proc_rank}:", node_family.offsets())
print(f"Family on proc {mpi.proc_rank}\n{node_family.as_array()}")
print(
    f"Nodes on proc {mpi.proc_rank} are distributed accross {node_family.number_of_domains()} domains."
)
for dk, domain_nodes in enumerate(node_family):
    # print could be used to retrieve a two colums vector
    # print(domain_nodes.as_array())
    proc = np.unique(domain_nodes.proc)
    assert len(proc) == 1  # A single proc per domain
    # print(f"Domain {dk} nodes of proc {mpi.proc_rank} are held by proc {proc[0]}.")
    print(
Esempio n. 4
0

set_pT_distribution(simulation.node_states(), simulation.vertices()[:, 2])
set_pT_distribution(simulation.cell_states(),
                    simulation.compute_cell_centers()[:, 2])
set_pT_distribution(dirichlet, simulation.vertices()[:, 2])

standard_loop(
    simulation,
    initial_timestep=1,
    final_time=year,
    output_period=year / 12,
    # nitermax=1,
)

master_print("\n", "-" * 10, "closing the well", "-" * 10)

producers_data = list(simulation.producers_data())
assert len(producers_data) == 1
producers_data[0].imposed_flowrate = 0

standard_loop(
    simulation,
    initial_timestep=1,
    final_time=year,
    output_period=year / 12,
    # nitermax=1,
)

from ComPASS.postprocess import postprocess