def ComputeL1NormOfError(method, j_var, k_var):
    E = 0.
    E_r = 0.
    main_path = os.getcwd()
    with open(
            main_path + '/coors_' + str(method) + str(j_var) + str(k_var) +
            '.txt', 'r') as f_coors:
        ch_pp.include_history_force = 1
        sim = ch.AnalyticSimulator(ch_pp)
        i = 0
        for line in f_coors:
            i += 1
            coor = line.split()
            coor = [float(comp) for comp in coor]
            exact_coor = [0.] * 3
            sim.CalculatePosition(exact_coor, coor[0])
            x = exact_coor[0] * ch_pp.R
            y = exact_coor[1] * ch_pp.R
            r = Radius(coor[1:3])
            exact_r = Radius([x, y])
            delta_coor = [coor[1] - x, coor[2] - y]
            #E = max(E, Radius(delta_coor) / exact_r)
            #E_r = max(E_r, (r - exact_r) / exact_r)
            E += Radius(delta_coor) / exact_r
            E_r += (r - exact_r) / exact_r
    return E / i, E_r / i
Esempio n. 2
0
    def SetCustomBetaParameters(self, dictionary): # These are input parameters that have not yet been transferred to the interface
        var_names = [k for k in dictionary.keys()]
        var_values = [k for k in dictionary.values()]

        for name, value in zip(var_names, var_values):
            if name == 'simulation_time':
                simulation_time = value
            elif name == 'basset_force_type':
                basset_force_type = value
            elif name == 'Nq':
                Nq = value
            elif name == 'm':
                m = value
            elif name == 'number_of_quadrature_steps_in_window':
                number_of_quadrature_steps_in_window = value

        self.pp.CFD_DEM.FinalTime = simulation_time
        self.pp.CFD_DEM.fluid_already_calculated = 0
        self.pp.CFD_DEM.recovery_echo_level = 1
        self.pp.CFD_DEM.gradient_calculation_type = 5
        self.pp.CFD_DEM.pressure_grad_recovery_type = 1
        self.pp.CFD_DEM.store_full_gradient = 1
        self.pp.CFD_DEM.laplacian_calculation_type = 0
        self.pp.CFD_DEM.do_search_neighbours = False
        self.pp.CFD_DEM.material_acceleration_calculation_type = 2
        self.pp.CFD_DEM.faxen_force_type = 0
        self.pp.CFD_DEM.vorticity_calculation_type = 0
        self.pp.CFD_DEM.print_FLUID_VEL_PROJECTED_RATE_option = 0
        self.pp.CFD_DEM.print_MATERIAL_FLUID_ACCEL_PROJECTED_option = True
        self.pp.CFD_DEM.basset_force_type = basset_force_type
        self.pp.CFD_DEM.print_BASSET_FORCE_option = 1
        self.pp.CFD_DEM.basset_force_integration_type = 1
        self.pp.CFD_DEM.n_init_basset_steps = 2
        self.pp.CFD_DEM.time_steps_per_quadrature_step = Nq
        self.pp.CFD_DEM.delta_time_quadrature = self.pp.CFD_DEM.time_steps_per_quadrature_step * self.pp.CFD_DEM.MaxTimeStep
        self.pp.CFD_DEM.quadrature_order = 2
        self.pp.CFD_DEM.time_window = 0.5
        self.pp.CFD_DEM.number_of_exponentials = m
        self.pp.CFD_DEM.number_of_quadrature_steps_in_window = number_of_quadrature_steps_in_window
        self.pp.CFD_DEM.print_steps_per_plot_step = 1
        self.pp.CFD_DEM.PostCationConcentration = False
        self.pp.CFD_DEM.do_impose_flow_from_field = False
        self.pp.CFD_DEM.print_MATERIAL_ACCELERATION_option = True
        self.pp.CFD_DEM.print_FLUID_ACCEL_FOLLOWING_PARTICLE_PROJECTED_option = False
        self.pp.CFD_DEM.print_VORTICITY_option = 0
        self.pp.CFD_DEM.print_MATERIAL_ACCELERATION_option = False
        self.pp.CFD_DEM.print_VELOCITY_GRADIENT_option = 0
        # Making the fluid step an exact multiple of the DEM step
        self.pp.Dt = int(self.pp.Dt / self.pp.CFD_DEM.MaxTimeStep) * self.pp.CFD_DEM.MaxTimeStep
        self.pp.viscosity_modification_type = 0.0
        self.pp.CFD_DEM.fluid_domain_volume = 0.5 ** 2 * 2 * math.pi # write down the volume you know it has

        import chandelier_parameters as ch_pp
        import chandelier as ch
        self.ch_pp = ch_pp
        self.ch = ch
        self.ch_pp.include_history_force = bool(self.pp.CFD_DEM.basset_force_type)

        #import quadrature as quad
        self.ch.sim = ch.AnalyticSimulator(self.ch_pp)
Esempio n. 3
0
    def __init__(self, pp, path):
        self.sim = ch.AnalyticSimulator(ch_pp)
        self.sim.CalculateNonDimensionalVars()
        self.path = path + '/candelier_results.h5py'
        self.dt = pp.CFD_DEM.MaxTimeStep
        self.N_q = pp.CFD_DEM.time_steps_per_quadrature_step
        self.quadrature_order = pp.CFD_DEM.quadrature_order
        self.reading_index = 0
        self.times = []
        self.errors = []
        ch_pp.include_history_force = bool(pp.CFD_DEM.basset_force_type)

        if pp.CFD_DEM.basset_force_type == 2:
            self.method = 'Daitche'
        else:
            self.method = 'Hinsberg'
            self.m = pp.CFD_DEM.number_of_exponentials
            self.t_w = pp.CFD_DEM.time_window

        self.result_code = self.method + '_dt=' + str(self.dt) + '_Nq=' + str(self.N_q) + '_quadrature_order=' + str(self.quadrature_order)
        if self.method == 'Hinsberg':
            self.result_code += '_tw=' + str(self.t_w) + '_m=' + str(self.m)

        with h5py.File(self.path) as f:
            result = f.require_group(self.result_code)
            result.attrs['method'] = self.method
            result.attrs['dt'] = self.dt
            result.attrs['N_q'] = self.N_q
            result.attrs['quadrature_order'] = self.quadrature_order

            if self.method == 'Hinsberg':
                result.attrs['t_w'] = self.t_w
                result.attrs['m'] = self.m
Esempio n. 4
0
 def SetCustomBetaParameters(
     self, custom_parameters
 ):  # These are input parameters that have not yet been transferred to the interface
     BaseAlgorithm.SetCustomBetaParameters(self, custom_parameters)
     ch_pp.include_history_force = bool(
         self.pp.CFD_DEM["basset_force_type"].GetInt())
     ch.sim = ch.AnalyticSimulator(ch_pp)
     self.frame_angular_vel = Vector(
         [0, 0, self.pp.CFD_DEM["angular_velocity_of_frame_Z"].GetDouble()])
     self.is_rotating_frame = self.pp.CFD_DEM[
         "frame_of_reference_type"].GetInt()
Esempio n. 5
0
#G
linear_solver = CGSolver()
scheme = ResidualBasedIncrementalUpdateStaticScheme()
post_process_strategy = ResidualBasedLinearStrategy(fluid_model_part, scheme, linear_solver, False, True, False, False)
#Z

# CHANDELIER BEGIN
import math 
import cmath
import mpmath
import matplotlib.pyplot as plt

import chandelier_parameters as ch_pp
import chandelier as ch
import quadrature as quad
sim = ch.AnalyticSimulator(ch_pp)

post_utils.Writeresults(time)
coors = [None] * 3
exact_vel = [None] * 3 
Dt_DEM_inv = 1.0 / Dt_DEM                    
vel = [0., 0.0, 0.] 
old_vel = [v for v in vel] 
H = [0.] * 3
H_old = [0.] * 3
Delta_H = [0.] * 3 
exact_Delta_H = [0.] * 3
basset_force = [0.] * 3
exact_basset_force = [0.] * 3 
sim.CalculatePosition(coors, 0.0)      
times = [0.0]