Пример #1
0
def test_scalar_constant():
    mesh = UnitCubeMesh(MPI.COMM_WORLD, 2, 2, 2)
    c = Constant(mesh, 1.0)
    assert c.value.shape == ()
    assert c.value == 1.0
    c.value += 1.0
    assert c.value == 2.0
    c.value = 3.0
    assert c.value == 3.0
Пример #2
0
def test_wrong_dim():
    mesh = UnitCubeMesh(MPI.COMM_WORLD, 2, 2, 2)
    c = Constant(mesh, [1.0, 2.0])
    assert c.value.shape == (2, )
    with pytest.raises(ValueError):
        c.value = [1.0, 2.0, 3.0]
Пример #3
0
co2_flux = {}
heat_flux = {}

J, F, expr_compiled =\
    fecoda.main.compile_forms(intern_var0, intern_var1, w0, w1, f, g,
                              heat_flux, water_flux, co2_flux, t, dt,
                              [], [dx(3)])

strain = Function(intern_var0["eps_cr_kel"].function_space)

t0 = time()

# Global time loop
for k in range(len(dtimes)):

    t.value = times[k]
    dt.value = dtimes[k]

    if rank == 0:
        logger.info(79 * "#")
        logger.info("Time: {:2.2} days.".format(t.value))
        logger.info("Step: {}".format(k))
        logger.info(79 * "#")

    bcs_displ = [
        DirichletBC(displ_bc2, bottom_dofs, w0["displ"].function_space)
    ]
    if t.value == afterload_times[0]:
        df.value = args.sigma
    else:
        df.value = 0.0
Пример #4
0
log = {"times": [], "disp": []}

# Global time loop
for k in range(len(dtimes)):

    # If time is greater than validity of Kelvin chain
    # sampling last time
    if times[k] + dtimes[k] > 0.5 * fecoda.mps.tau[-1]:
        if rank == 0:
            logger.warning(
                "Validity of Kelvin sampling reached in {} days".format(
                    t.value))
        break

    t.value = times[k]
    dt.value = dtimes[k]

    if rank == 0:
        logger.info(79 * "#")
        logger.info(f"Time: {t.value} days.")
        logger.info(f"Dtime: {dt.value}")
        logger.info("Step: {}".format(k))
        logger.info(79 * "#")

    bcs_displ = []
    bcs_temp = []
    bcs_hum = []
    bcs_co2 = []

    bcs_displ.append(DirichletBC(displ_bc, leftW0))
Пример #5
0
# Define variational problem for projection
proj_rhs = Form(ufl.inner(intern_var0["dmg"], ufl.TestFunction(DMG)) * dx)
mass_DMG = assemble_matrix(
    ufl.inner(ufl.TrialFunction(DMG), ufl.TestFunction(DMG)) * dx, [])
mass_DMG.assemble()

dscale = 1.0
apply_load = True

t0 = time()

# Global time loop
for k in range(len(dtimes)):

    t.value = times[k]
    dt.value = dtimes[k]

    # If time is greater than validity of Kelvin chain
    # sampling last time
    if t.value > 0.5 * fecoda.mps.tau[-1]:
        if rank == 0:
            logger.warning(
                "Validity of Kelvin sampling reached in {} days".format(
                    t.value))
        break

    bcs_displ = []
    bcs_temp = []
    bcs_hum = []
    bcs_co2 = []
Пример #6
0
    # Scale of last successful call to solver
    dscale = 1.0

    # If time is greater than validity of Kelvin chain
    # sampling last time
    if times[k] + dtimes[k] > 0.5 * fecoda.mps.tau[-1]:
        if rank == 0:
            logger.warning(
                "Validity of Kelvin sampling reached in {} days".format(
                    t.value))
        break

    if k == 0:
        dforce_val = args.force
    elif times[k] == times_replaced[0]:
        force.value = 0.0
        dforce_val = args.force
    else:
        dforce_val = 0.0

    while scale < 1.0:

        dscale = min(1.0 - scale, 2.0 * dscale)

        t.value = times[k] + scale * dtimes[k]
        dt.value = dscale * dtimes[k]
        dforce.value = dscale * dforce_val

        if rank == 0:
            logger.info(79 * "#")
            logger.info(f"Time: {times[k]} + {(scale) * dtimes[k]} days.")