def simulate(simulation_dir, params):
    '\n    Run simulation.\n\n    @param simulation_dir: the simulation directory\n    @param params: the simulation parameters\n    @return: the simulation log content\n    @raise TypeError: if any input parameter is not of required type\n    @raise ValueError: if any input parameter is None/empty, or any field of SimulationParameters is not\n                        of valid value\n    @raise ServiceError: if any other error occurred when launching the simulation\n    '
    signature = (__name__ + '.simulate()')
    helper.log_entrance(_LOGGER, signature, {'simulation_dir': simulation_dir, 'params': params})
    helper.check_not_none_nor_empty(simulation_dir, 'simulation_dir')
    helper.check_is_directory(simulation_dir, 'simulation_dir')
    helper.check_type_value(params, 'params', SimulationParameters, False)
    helper.check_not_none_nor_empty(params.rho, 'params.rho')
    helper.check_not_none_nor_empty(params.g, 'params.g')
    helper.check_not_none_nor_empty(params.depth, 'params.depth')
    helper.check_not_none_nor_empty(params.xeff, 'params.xeff')
    helper.check_not_none_nor_empty(params.yeff, 'params.yeff')
    helper.check_not_none_nor_empty(params.wave_frequencies, 'params.wave_frequencies')
    helper.check_not_none_nor_empty(params.min_wave_frequencies, 'params.min_wave_frequencies')
    helper.check_not_none_nor_empty(params.max_wave_frequencies, 'params.max_wave_frequencies')
    helper.check_not_none_nor_empty(params.wave_directions, 'params.wave_directions')
    helper.check_not_none_nor_empty(params.min_wave_directions, 'params.min_wave_directions')
    helper.check_not_none_nor_empty(params.max_wave_direction, 'params.max_wave_direction')
    helper.check_not_none_nor_empty(params.indiq_solver, 'params.indiq_solver')
    helper.check_not_none_nor_empty(params.ires, 'params.ires')
    helper.check_not_none_nor_empty(params.tol_gmres, 'params.tol_gmres')
    helper.check_not_none_nor_empty(params.max_iterations, 'params.max_iterations')
    helper.check_not_none_nor_empty(params.save_potential, 'params.save_potential')
    helper.check_not_none_nor_empty(params.green_tabulation_numx, 'params.green_tabulation_numx')
    helper.check_not_none_nor_empty(params.green_tabulation_numz, 'params.green_tabulation_numz')
    helper.check_not_none_nor_empty(params.green_tabulation_simpson_npoints, 'params.green_tabulation_simpson_npoints')
    helper.check_not_none_nor_empty(params.use_ode_influence_coefficients, 'params.use_ode_influence_coefficients')
    helper.check_not_none_nor_empty(params.use_higher_order, 'params.use_higher_order')
    helper.check_not_none_nor_empty(params.num_panel_higher_order, 'params.num_panel_higher_order')
    helper.check_not_none_nor_empty(params.b_spline_order, 'params.b_spline_order')
    helper.check_not_none_nor_empty(params.use_dipoles_implementation, 'params.use_dipoles_implementation')
    helper.check_not_none_nor_empty(params.thin_panels, 'params.thin_panels')
    helper.check_not_none_nor_empty(params.compute_drift_forces, 'params.compute_drift_forces')
    helper.check_not_none_nor_empty(params.remove_irregular_frequencies, 'params.remove_irregular_frequencies')
    helper.check_not_none_nor_empty(params.compute_yaw_moment, 'params.compute_yaw_moment')
    helper.check_type_value(params.floating_bodies, 'params.floating_bodies', list, True)
    if (params.floating_bodies is not None):
        for body in params.floating_bodies:
            helper.check_type_value(body, 'params.floating_bodies item', FloatingBody, False)
            helper.check_not_none_nor_empty(body.mesh_file, 'body.mesh_file')
            helper.check_not_none_nor_empty(body.points, 'body.points')
            helper.check_not_none_nor_empty(body.panels, 'body.panels')
            helper.check_not_none_nor_empty(body.degrees_of_freedom, 'body.degrees_of_freedom')
            helper.check_not_none_nor_empty(body.resulting_generalised_forces, 'body.resulting_generalised_forces')
            helper.check_not_none_nor_empty(body.additional_info_lines, 'body.additional_info_lines')
    try:
        with h5py.File(os.path.join(simulation_dir, 'db.hdf5'), 'a') as hdf5_data:
            utility.write_calculations(params, hdf5_data)
        os.mkdir(os.path.join(simulation_dir, 'results'))
        simulation_log_path = os.path.join(simulation_dir, 'simulation_log.txt')
        custom_config = {'HDF5_FILE': os.path.join(simulation_dir, 'db.hdf5'), 'NEMOH_CALCULATIONS_FILE': None, 'NEMOH_INPUT_FILE': None, 'MESH_TEC_FILE': os.path.join(simulation_dir, 'mesh', 'mesh.tec'), 'FK_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'fkforce.tec'), 'RADIATION_COEFFICIENTS_TEC_FILE': os.path.join(simulation_dir, 'results', 'radiationcoefficients.tec'), 'DIFFRACTION_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'diffractionforce.tec'), 'EXCITATION_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'excitationforce.tec'), 'IRF_TEC_FILE': os.path.join(simulation_dir, 'results', 'irf.tec'), 'WAVE_FIELD_TEC_FILE': os.path.join(simulation_dir, 'results', 'WaveField.tec'), 'GREEN_TABULATION_NUMX': int(params.green_tabulation_numx), 'GREEN_TABULATION_NUMZ': int(params.green_tabulation_numz), 'GREEN_TABULATION_SIMPSON_NPOINTS': int(params.green_tabulation_simpson_npoints), 'USE_ODE_INFLUENCE_COEFFICIENTS': bool(int(params.use_ode_influence_coefficients)), 'USE_HIGHER_ORDER': bool(int(params.use_higher_order)), 'NUM_PANEL_HIGHER_ORDER': int(params.num_panel_higher_order), 'B_SPLINE_ORDER': int(params.b_spline_order), 'USE_DIPOLES_IMPLEMENTATION': bool(int(params.use_dipoles_implementation)), 'THIN_PANELS': [int(i) for i in params.thin_panels.split()], 'COMPUTE_DRIFT_FORCES': bool(int(params.compute_drift_forces)), 'COMPUTE_YAW_MOMENT': bool(int(params.compute_yaw_moment)), 'REMOVE_IRREGULAR_FREQUENCIES': bool(int(params.remove_irregular_frequencies))}
        _LOGGER.debug('Start preProcessor function.')
        run_thread(preprocessor.preprocess, (custom_config,), simulation_log_path)
        _LOGGER.debug('End preProcessor function.')
        _LOGGER.debug('Start solver function.')
        output = run_thread(solver.solve, (custom_config,), None)
        with open(simulation_log_path, 'a') as log_file:
            log_file.write(output)
        _LOGGER.debug('End solver function.')
        with open(simulation_log_path, 'r') as log_file:
            ret = log_file.read()
            helper.log_exit(_LOGGER, signature, [ret])
            return ret
    except Exception as e:
        helper.log_exception(_LOGGER, signature, e)
        raise ServiceError(('Error occurs when doing simulation. Caused by:\n' + unicode(str(e))))
Run simulation.

@param simulation_dir: the simulation directory
@param params: the simulation parameters
@return: the simulation log content
@raise TypeError: if any input parameter is not of required type
@raise ValueError: if any input parameter is None/empty, or any field of SimulationParameters is not
                    of valid value
@raise ServiceError: if any other error occurred when launching the simulation
def simulate(simulation_dir, params):
    '\n    Run simulation.\n\n    @param simulation_dir: the simulation directory\n    @param params: the simulation parameters\n    @return: the simulation log content\n    @raise TypeError: if any input parameter is not of required type\n    @raise ValueError: if any input parameter is None/empty, or any field of SimulationParameters is not\n                        of valid value\n    @raise ServiceError: if any other error occurred when launching the simulation\n    '
    signature = (__name__ + '.simulate()')
    helper.log_entrance(_LOGGER, signature, {'simulation_dir': simulation_dir, 'params': params})
    helper.check_not_none_nor_empty(simulation_dir, 'simulation_dir')
    helper.check_is_directory(simulation_dir, 'simulation_dir')
    helper.check_type_value(params, 'params', SimulationParameters, False)
    helper.check_not_none_nor_empty(params.rho, 'params.rho')
    helper.check_not_none_nor_empty(params.g, 'params.g')
    helper.check_not_none_nor_empty(params.depth, 'params.depth')
    helper.check_not_none_nor_empty(params.xeff, 'params.xeff')
    helper.check_not_none_nor_empty(params.yeff, 'params.yeff')
    helper.check_not_none_nor_empty(params.wave_frequencies, 'params.wave_frequencies')
    helper.check_not_none_nor_empty(params.min_wave_frequencies, 'params.min_wave_frequencies')
    helper.check_not_none_nor_empty(params.max_wave_frequencies, 'params.max_wave_frequencies')
    helper.check_not_none_nor_empty(params.wave_directions, 'params.wave_directions')
    helper.check_not_none_nor_empty(params.min_wave_directions, 'params.min_wave_directions')
    helper.check_not_none_nor_empty(params.max_wave_direction, 'params.max_wave_direction')
    helper.check_not_none_nor_empty(params.indiq_solver, 'params.indiq_solver')
    helper.check_not_none_nor_empty(params.ires, 'params.ires')
    helper.check_not_none_nor_empty(params.tol_gmres, 'params.tol_gmres')
    helper.check_not_none_nor_empty(params.max_iterations, 'params.max_iterations')
    helper.check_not_none_nor_empty(params.save_potential, 'params.save_potential')
    helper.check_not_none_nor_empty(params.green_tabulation_numx, 'params.green_tabulation_numx')
    helper.check_not_none_nor_empty(params.green_tabulation_numz, 'params.green_tabulation_numz')
    helper.check_not_none_nor_empty(params.green_tabulation_simpson_npoints, 'params.green_tabulation_simpson_npoints')
    helper.check_not_none_nor_empty(params.use_ode_influence_coefficients, 'params.use_ode_influence_coefficients')
    helper.check_not_none_nor_empty(params.use_higher_order, 'params.use_higher_order')
    helper.check_not_none_nor_empty(params.num_panel_higher_order, 'params.num_panel_higher_order')
    helper.check_not_none_nor_empty(params.b_spline_order, 'params.b_spline_order')
    helper.check_not_none_nor_empty(params.use_dipoles_implementation, 'params.use_dipoles_implementation')
    helper.check_not_none_nor_empty(params.thin_panels, 'params.thin_panels')
    helper.check_not_none_nor_empty(params.compute_drift_forces, 'params.compute_drift_forces')
    helper.check_not_none_nor_empty(params.remove_irregular_frequencies, 'params.remove_irregular_frequencies')
    helper.check_not_none_nor_empty(params.compute_yaw_moment, 'params.compute_yaw_moment')
    helper.check_type_value(params.floating_bodies, 'params.floating_bodies', list, True)
    if (params.floating_bodies is not None):
        for body in params.floating_bodies:
            helper.check_type_value(body, 'params.floating_bodies item', FloatingBody, False)
            helper.check_not_none_nor_empty(body.mesh_file, 'body.mesh_file')
            helper.check_not_none_nor_empty(body.points, 'body.points')
            helper.check_not_none_nor_empty(body.panels, 'body.panels')
            helper.check_not_none_nor_empty(body.degrees_of_freedom, 'body.degrees_of_freedom')
            helper.check_not_none_nor_empty(body.resulting_generalised_forces, 'body.resulting_generalised_forces')
            helper.check_not_none_nor_empty(body.additional_info_lines, 'body.additional_info_lines')
    try:
        with h5py.File(os.path.join(simulation_dir, 'db.hdf5'), 'a') as hdf5_data:
            utility.write_calculations(params, hdf5_data)
        os.mkdir(os.path.join(simulation_dir, 'results'))
        simulation_log_path = os.path.join(simulation_dir, 'simulation_log.txt')
        custom_config = {'HDF5_FILE': os.path.join(simulation_dir, 'db.hdf5'), 'NEMOH_CALCULATIONS_FILE': None, 'NEMOH_INPUT_FILE': None, 'MESH_TEC_FILE': os.path.join(simulation_dir, 'mesh', 'mesh.tec'), 'FK_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'fkforce.tec'), 'RADIATION_COEFFICIENTS_TEC_FILE': os.path.join(simulation_dir, 'results', 'radiationcoefficients.tec'), 'DIFFRACTION_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'diffractionforce.tec'), 'EXCITATION_FORCE_TEC_FILE': os.path.join(simulation_dir, 'results', 'excitationforce.tec'), 'IRF_TEC_FILE': os.path.join(simulation_dir, 'results', 'irf.tec'), 'WAVE_FIELD_TEC_FILE': os.path.join(simulation_dir, 'results', 'WaveField.tec'), 'GREEN_TABULATION_NUMX': int(params.green_tabulation_numx), 'GREEN_TABULATION_NUMZ': int(params.green_tabulation_numz), 'GREEN_TABULATION_SIMPSON_NPOINTS': int(params.green_tabulation_simpson_npoints), 'USE_ODE_INFLUENCE_COEFFICIENTS': bool(int(params.use_ode_influence_coefficients)), 'USE_HIGHER_ORDER': bool(int(params.use_higher_order)), 'NUM_PANEL_HIGHER_ORDER': int(params.num_panel_higher_order), 'B_SPLINE_ORDER': int(params.b_spline_order), 'USE_DIPOLES_IMPLEMENTATION': bool(int(params.use_dipoles_implementation)), 'THIN_PANELS': [int(i) for i in params.thin_panels.split()], 'COMPUTE_DRIFT_FORCES': bool(int(params.compute_drift_forces)), 'COMPUTE_YAW_MOMENT': bool(int(params.compute_yaw_moment)), 'REMOVE_IRREGULAR_FREQUENCIES': bool(int(params.remove_irregular_frequencies))}
        _LOGGER.debug('Start preProcessor function.')
        run_thread(preprocessor.preprocess, (custom_config,), simulation_log_path)
        _LOGGER.debug('End preProcessor function.')
        _LOGGER.debug('Start solver function.')
        output = run_thread(solver.solve, (custom_config,), None)
        with open(simulation_log_path, 'a') as log_file:
            log_file.write(output)
        _LOGGER.debug('End solver function.')
        with open(simulation_log_path, 'r') as log_file:
            ret = log_file.read()
            helper.log_exit(_LOGGER, signature, [ret])
            return ret
    except Exception as e:
        helper.log_exception(_LOGGER, signature, e)
        raise ServiceError(('Error occurs when doing simulation. Caused by:\n' + unicode(str(e))))