示例#1
0
    def MonteCarloTest(self):
        with KratosUnittest.WorkFolderScope(os.path.join(self.folder_name),__file__,add_to_path=True):
            import KratosMultiphysics.MultilevelMonteCarloApplication.mc_utilities as mc_utilities
            from poisson_square_2d_kratos.simulation_definition import SimulationScenario

            # set the ProjectParameters.json path
            project_parameters_path = "problem_settings/parameters_poisson_square_2d_coarse.json"
            # set parameters of the MC simulation"""
            parameters_x_monte_carlo_path = "problem_settings/parameters_x_monte_carlo.json"
            # contruct MonteCarlo or MultilevelMonteCarlo class
            mc_manager = mc_utilities.MonteCarlo(parameters_x_monte_carlo_path,project_parameters_path,SimulationScenario)
            # execute algorithm
            mc_manager.Run()
            """delete files"""
            kratos_utilities.DeleteFileIfExisting(os.path.join(self.folder_name,"poisson_square_2d.post.bin"))
            kratos_utilities.DeleteFileIfExisting(os.path.join(self.folder_name,"poisson_square_2d.post.lst"))
示例#2
0
# TODO: use json file instead of defining in the main file all the parameters

if __name__ == '__main__':
    """  __ __  __
        |  V  |/ _|
        | \_/ | (_
        |_| |_|\__|
    """

    # set the ProjectParameters.json path
    project_parameters_path = "problem_settings/parameters_poisson_square_2d_finer.json"
    # customize setting parameters of the MC simulation"""
    parameters_x_monte_carlo_path = "problem_settings/parameters_x_monte_carlo.json"
    # contruct MonteCarlo or MultilevelMonteCarlo class
    mc_manager = mc_utilities.MonteCarlo(parameters_x_monte_carlo_path,
                                         project_parameters_path,
                                         SimulationScenario)
    # execute algorithm
    mc_manager.Run()
    """ __ __ _   __ __  __
       |  V  | | |  V  |/ _|
       | \_/ | |_| \_/ | (_
       |_| |_|___|_| |_|\__|
    """

    # set the ProjectParameters.json path
    project_parameters_path = "problem_settings/parameters_poisson_square_2d_finer.json"
    # customize setting parameters of the MLMC simulation
    parameters_x_monte_carlo_path = "problem_settings/parameters_x_monte_carlo.json"
    # customize setting parameters of the metric of the adaptive refinement utility and setting parameters of the remesh of the adaptive refinement utility
    parameters_refinement_path = "problem_settings/parameters_refinement.json"