示例#1
0
def main():
    # ----- Setup ----- #
    # Simulation parameters
    Nx = 30
    duration = 3.0
    height = 1.0
    width = 1.0

    # Other parameters
    rho0 = 1000.0
    XSPH = False
    plot = True

    # Create some particles
    r0, pA = create_particles(Nx, rho0, width, height)

    # Create the solver
    kernel = CubicSpline()
    method = WCSPH(height=height, rho0=rho0, r0=r0, useXSPH=XSPH, Pb=0)
    integrator = PEC(useXSPH=XSPH, strict=False)
    solver = Solver(method,
                    integrator,
                    kernel,
                    duration,
                    quick=False,
                    incrementalWriteout=False,
                    exportProperties=['x', 'y', 'p', 'vx', 'vy'])

    # Add the particles
    solver.addParticles(pA)

    # Setup
    solver.setup()

    # ----- Run ----- #
    solver.run()

    # ----- Post ----- #
    # Output timing
    solver.timing()

    # Output
    exportPath = f'{sys.path[0]}/containment.hdf5'
    solver.save(exportPath)

    if plot == True:
        plt = Plot(exportPath,
                   title=f'Containment (2D); {len(pA)} particles',
                   xmin=-0.2,
                   xmax=1.2,
                   ymin=-0.2,
                   ymax=1.2)
        plt.save(f'{sys.path[0]}/containment.mp4')
示例#2
0
def main():
    # ----- Setup ----- #
    # Simulation parameters
    duration = 5.0  # Duration of the simulation [s]
    height = 10.0  # Height of the fluid box [m]
    width = 60.0  # Width of the fluid box [m]
    compress = 1.0  # (vertical) compression factor [-]

    # Computed parameters
    ice_max = width / 2.0

    # Coupling object
    P = {'g': 9.81, 'L_interface': [], 'F_a': [], 'Pressure': [], 'F_r': []}

    # Other parameters
    rho0 = 1025.0
    XSPH = True
    print('Three different models are implemented.')
    print(
        '0. A cantilever beam, with a static force on the end, above the water.'
    )
    print(
        '1. An short sheet of ice (cantilever beam) floating on water without any force.'
    )
    print(
        '2. An long sheet of ice (cantilever beam) floating on water without any force.'
    )
    print('3. --')
    print('4. The ice-sheet above the water.')
    print('5. The scaled ice-sheet model (Valanto, 1992).')
    print('6. Full scale model (Keijdener, 2018).')
    P['model'] = int(input('Select model: '))
    plot = input('Create animation after solving? (y/n) ').lower() == 'y'

    if P['model'] > 6 or P['model'] < 0:
        raise 'Invalid model selected'

    if P['model'] == 5:
        height = 1.0
        width = 2.0
        ice_max = 1.0

    Nx = int(input('Number of particles in x-direction (100 > N > 10): '))
    # if Nx > 500 or Nx < 10:
    # raise 'Invalid number of particles.'

    # Create some particles
    y00, r0, pA = create_particles(Nx, rho0, width, height, ice_max, P,
                                   compress)
    P['y0'] = y00

    # -- Create matrix -- #
    # Beam/Ice properties
    L = ice_max + r0  # Total Length [m]; one third overlap with water, two thirds to the left.
    b = 1  # Width of the beam [m]
    h = 1  # Height of the beam [m]
    v = 0.3  # Poisson ratio [-]
    P['alpha'] = 15 / 180 * np.pi  # Angle of the hull [rad]
    P['ice_v'] = 0.2  # Velocity of the ice-sheet [m/s]
    P['ice_fy_comp'] = 11e3  # Compressive strength of the ice [Pa]
    P['m2_stiffness'] = 15e5  # Rigid spring stiffness [N/m]
    P['b'] = b

    # General properties
    if P['model'] in [0]:
        E = 200e9
        rho = 7800
        h = 1 / 33.33
    elif P['model'] in [1, 2]:
        E = 140e6
        rho = 916.0
        duration = 1.0
        if P['model'] == 1:
            L = 2 * ice_max
        elif P['model'] == 2:
            L = 5 * ice_max
    elif P['model'] in [5]:
        duration = 1.5
        L = 5 * ice_max
        h = 1 / 33.33
        b = 0.34
        P['b'] = b
        E = 140e6  # Young's Modulus [Pa]
        rho = 916.0
    elif P['model'] in [6]:
        L = 1.9 * ice_max
        P['ice_v'] = float(input('Ice velocity: '))
        duration = float(input('Duration: '))
        E = 5e9 / (1 - v**2)
        P['ice_fy_comp'] = 6E5
        P['m2_stiffness'] = 50 * P['ice_fy_comp']
        P['alpha'] = 45 / 180 * np.pi
        rho = 925.0

    # Ice-penetration
    P['mode'] = 1  # Start in crushing mode.
    P['penetration'] = [0]  # Start with zero penetration.
    P['t_trans'] = 0  # Transition time [s]
    P['hh'] = h / 2

    # Compute one-time dynamic h.
    P['h'] = 1.6 * r0

    # Compute properties
    n = len(pA[pA['label'] == ParticleType.Coupled])  # Number of Nodes [-]
    A = b * h  # Area [m^3]
    I = 1 / 12 * b * h**3  # Area moment of Inertia [kg/m^3]
    P['L_n'] = L / n  # Node length [m]
    P['m'] = rho * A  # Nodal mass [kg/m]

    # Assign some props
    P['E'] = E
    P['pois'] = v

    # Compute stiffness and mass matrices
    K, M = createMatrix(n, E, I, A, rho, P['L_n'])

    # Set mass
    pA[pA['label'] == ParticleType.Coupled]['m'] = P['m']

    # Compute damping matrix
    xi = 2e1  # Damping factor [-]
    c_crit = np.sqrt(rho * A * rho0 * P['g'])  # Critical damping factor [-]
    C = np.eye(n) * 2 * xi * c_crit  # Damping matrix [N/s]

    # Create the solver
    newmark = NewmarkBeta(beta=1 / 4, gamma=1 / 2, M=M, K=K, C=C)
    kernel = Wendland()
    method = WCSPH(height=height,
                   rho0=rho0,
                   r0=r0,
                   useXSPH=XSPH,
                   Pb=0,
                   useSummationDensity=False)
    integrator = PEC(useXSPH=XSPH, strict=False)
    solver = Solver(method,
                    integrator,
                    kernel,
                    duration,
                    quick=False,
                    damping=0.0,
                    incrementalWriteout=False,
                    maxSettle=1800,
                    customSettle=custom_settling,
                    exportProperties=['x', 'y', 'p', 'rho'],
                    coupling=coupling,
                    couplingIntegrator=newmark,
                    couplingProperties=P,
                    timeStep=None)

    # Add the particles
    solver.addParticles(pA)

    # Setup
    solver.setup()

    # ----- Run ----- #
    solver.run()

    # ----- Post ----- #
    # Output timing
    solver.timing()

    # Output
    exportPath = '{0}/IceBreak-{1}.hdf5'.format(sys.path[0], P['model'])
    solver.save(exportPath, True, solver.couplingProperties)

    # Create an animation.
    if plot == True:
        title = 'IceBreak (2D); {0} particles'.format(len(pA))
        plt = Plot(exportPath,
                   title=title,
                   xmin=-1,
                   xmax=width + 2 * r0,
                   ymin=-2 * r0,
                   ymax=height * 1.3 + 2 * r0)
        plt.save('{0}/IceBreak-{1}.mp4'.format(sys.path[0], P['model']))

    # Load the file and determine breaking length
    post(exportPath)