예제 #1
0
def test_hertz_agreement_static_load_fftw():
    """ Test that the load controlled static step gives approximately the same answer as the
    analytical hertz solver

    """
    try:
        import pyfftw  # noqa: F401
    except ImportError:
        warnings.warn(
            "Could not import pyfftw, could not test the fftw backend")
        return

    with slippy.OverRideCuda():
        # make surfaces
        flat_surface = s.FlatSurface(shift=(0, 0))
        round_surface = s.RoundSurface((1, 1, 1),
                                       extent=(0.006, 0.006),
                                       shape=(255, 255),
                                       generate=True)
        # set materials
        steel = c.Elastic('Steel', {'E': 200e9, 'v': 0.3})
        aluminum = c.Elastic('Aluminum', {'E': 70e9, 'v': 0.33})
        flat_surface.material = aluminum
        round_surface.material = steel
        # create model
        my_model = c.ContactModel('model-1', round_surface, flat_surface)
        # set model parameters
        total_load = 100
        my_step = c.StaticStep('contact', normal_load=total_load)
        my_model.add_step(my_step)

        out = my_model.solve(skip_data_check=True)

        final_load = sum(out['loads'].z.flatten() *
                         round_surface.grid_spacing**2)

        # check the converged load is the same as the set load
        npt.assert_approx_equal(final_load, total_load, 3)

        # get the analytical hertz result
        a_result = c.hertz_full([1, 1], [np.inf, np.inf], [200e9, 70e9],
                                [0.3, 0.33], 100)

        # check max pressure
        npt.assert_approx_equal(a_result['max_pressure'],
                                max(out['loads'].z.flatten()), 2)

        # check contact area
        found_area = round_surface.grid_spacing**2 * sum(
            out['contact_nodes'].flatten())
        npt.assert_approx_equal(a_result['contact_area'], found_area, 2)

        # check deflection
        npt.assert_approx_equal(a_result['total_deflection'],
                                out['interference'], 4)
예제 #2
0
def test_hertz_agreement_static_interference_fftw():
    try:
        import pyfftw  # noqa: F401
        slippy.CUDA = False
    except ImportError:
        warnings.warn(
            "Could not import pyfftw, could not test the fftw backend")
        return

    with slippy.OverRideCuda():
        """Tests that the static normal interference step agrees with the analytical hertz solution"""
        flat_surface = s.FlatSurface(shift=(0, 0))
        round_surface = s.RoundSurface((1, 1, 1),
                                       extent=(0.006, 0.006),
                                       shape=(255, 255),
                                       generate=True)
        # set materials
        steel = c.Elastic('Steel', {'E': 200e9, 'v': 0.3})
        aluminum = c.Elastic('Aluminum', {'E': 70e9, 'v': 0.33})
        flat_surface.material = aluminum
        round_surface.material = steel
        # create model
        my_model = c.ContactModel('model-1', round_surface, flat_surface)

        set_load = 100

        a_result = c.hertz_full([1, 1], [np.inf, np.inf], [200e9, 70e9],
                                [0.3, 0.33], set_load)

        my_step = c.StaticStep('step',
                               interference=a_result['total_deflection'])
        my_model.add_step(my_step)
        final_state = my_model.solve()

        # check that the solution gives the set interference
        npt.assert_approx_equal(final_state['interference'],
                                a_result['total_deflection'])

        # check that the load converged to the correct results
        num_total_load = round_surface.grid_spacing**2 * sum(
            final_state['loads'].z.flatten())
        npt.assert_approx_equal(num_total_load, set_load, significant=4)

        # check that the max pressure is the same
        npt.assert_approx_equal(a_result['max_pressure'],
                                max(final_state['loads'].z.flatten()),
                                significant=2)

        # check that the contact area is in line with analytical solution
        npt.assert_approx_equal(a_result['contact_area'],
                                round_surface.grid_spacing**2 *
                                sum(final_state['contact_nodes'].flatten()),
                                significant=2)
def test_hertz_agreement_pk_static_load_cuda_spatial_im():
    """ Test that the load controlled static step gives approximately the same answer as the
    analytical hertz solver
    """
    try:
        import cupy  # noqa: F401
        slippy.CUDA = True
    except ImportError:
        return
    # make surfaces
    flat_surface = s.FlatSurface(shift=(0, 0))
    round_surface = s.RoundSurface((1, 1, 1), extent=(0.006, 0.006), shape=(255, 255), generate=True)
    # set materials
    steel_2 = c.Elastic('Steel_a', {'E': 200e9, 'v': 0.3}, use_frequency_domain=False)
    aluminum_2 = c.Elastic('Aluminum_a', {'E': 70e9, 'v': 0.33}, use_frequency_domain=False)
    flat_surface.material = aluminum_2
    round_surface.material = steel_2
    # create model
    my_model = c.ContactModel('model-1', round_surface, flat_surface)
    # set model parameters
    total_load = 100
    my_step = c.StaticStep('contact', normal_load=total_load, )
    my_model.add_step(my_step)

    out = my_model.solve(skip_data_check=True)

    final_load = sum(out['loads_z'].flatten() * round_surface.grid_spacing ** 2)

    # check the converged load is the same as the set load
    npt.assert_approx_equal(final_load, total_load, 3)

    # get the analytical hertz result
    a_result = c.hertz_full([1, 1], [np.inf, np.inf], [200e9, 70e9], [0.3, 0.33], 100)

    # check max pressure
    npt.assert_approx_equal(a_result['max_pressure'], max(out['loads_z'].flatten()), 3)

    # check contact area
    found_area = round_surface.grid_spacing ** 2 * sum(out['contact_nodes'].flatten())
    npt.assert_approx_equal(a_result['contact_area'], found_area, 2)

    # check deflection
    npt.assert_approx_equal(a_result['total_deflection'], out['interference'], 4)
예제 #4
0
def test_example_mixed_lubrication():
    """tests the mixed lubrication example"""
    radius = 0.01905  # The radius of the ball
    load = 800  # The load on the ball in N
    rolling_speed = 4  # The rolling speed in m/s (The mean speed of the surfaces)
    youngs_modulus = 200e9  # The youngs modulus of the surfaces
    p_ratio = 0.3  # The poission's ratio of the surfaces
    grid_size = 65  # The number of points in the descretisation grid
    eta_0 = 0.096  # Coefficient in the roelands pressure-viscosity equation
    roelands_p_0 = 1 / 5.1e-9  # Coefficient in the roelands pressure-viscosity equation
    roelands_z = 0.68  # Coefficient in the roelands pressure-viscosity equation

    # Solving the hertzian contact
    hertz_result = c.hertz_full([radius, radius], [float('inf'), float('inf')],
                                [youngs_modulus, youngs_modulus],
                                [p_ratio, p_ratio], load)
    hertz_pressure = hertz_result['max_pressure']
    hertz_a = hertz_result['contact_radii'][0]
    hertz_deflection = hertz_result['total_deflection']
    hertz_pressure_function = hertz_result['pressure_f']

    ball = s.RoundSurface((radius,) * 3, shape=(grid_size, grid_size),
                          extent=(hertz_a * 4, hertz_a * 4), generate=True)
    flat = s.FlatSurface()

    steel = c.Elastic('steel', {'E': youngs_modulus, 'v': p_ratio})
    ball.material = steel
    flat.material = steel

    oil = c.Lubricant('oil')  # Making a lubricant object to contain our sub models
    oil.add_sub_model('nd_viscosity', c.lubricant_models.nd_roelands(eta_0, roelands_p_0, hertz_pressure, roelands_z))
    oil.add_sub_model('nd_density', c.lubricant_models.nd_dowson_higginson(hertz_pressure))  # adding dowson higginson

    my_model = c.ContactModel('lubrication_test', ball, flat, oil)

    reynolds = c.UnifiedReynoldsSolver(time_step=0,
                                       grid_spacing=ball.grid_spacing,
                                       hertzian_pressure=hertz_pressure,
                                       radius_in_rolling_direction=radius,
                                       hertzian_half_width=hertz_a,
                                       dimentional_viscosity=eta_0,
                                       dimentional_density=872)

    # Find the hertzian pressure distribution as an initial guess
    x, y = ball.get_points_from_extent()
    x, y = x + ball._total_shift[0], y + ball._total_shift[1]
    hertzian_pressure_dist = hertz_pressure_function(x, y)

    # Making the step object
    step = c.IterSemiSystem('main', reynolds, rolling_speed, 1, no_time=True, normal_load=load,
                            initial_guess=[hertz_deflection, hertzian_pressure_dist],
                            relaxation_factor=0.05, max_it_interference=3000, rtol_interference=1e-3,
                            rtol_pressure=1e-4, no_update_warning=False)

    # Adding the step to the contact model
    my_model.add_step(step)
    state = my_model.solve()

    # gap is all greater than 0
    assert np.all(state['gap'] >= 0)
    # loads are all greater than or equal to 0
    assert np.all(state['pressure'] >= 0)
    # sum of pressures is total normal load and this has converged
    npt.assert_array_almost_equal(np.sum(state['pressure'])*ball.grid_spacing**2/load, 1.0, decimal=3)

    assert state['converged']