Straitified_time_updation

The program primarily focuses on checking and updating the single-particle distribution function.

check_legacy_of_distributions()

The function is mainly responsible for checking the single-particle distribution function;

There are two input parameters: distribution - representing the single-particle distribution function, and particle_type - indicating the type of particle.

To ensure thermal equilibrium in the system, fermions follow the Fermi-Dirac distribution, which has values ranging from 0 to 1.

distributions

length = len(degeneracy)
    
    # loop thorugh the particle types
    for i_type in range(length):
        
        # take the minimum value of the distribution
        f_min = cupy.amin(distribution[:,i_type])
        
        # if the distribution is smaller than zero, return False
        # very small statistical negative distributiona are legal
        if f_min < -10**(-19):
            position = cupy.argmin(cupy.array(distribution[:,i_type]))
            return 0,'f_min',f_min,i_type,position

        # for fermions we need to find the maximum value of the distributions as well
        if particle_type[i_type] == 1:
            f_max = cupy.amax(distribution[:,i_type])
            # return False if the maximum value is larger than g*1/(2*math.pi*hbar)**3 for fermions
            if f_max > degeneracy[i_type]*1/(2*math.pi*hbar)**3:
                position = cupy.argmin(cupy.array(distribution[:,i_type]))
                return 0,'f_max',f_max,i_type,position
        
    # if no issues are found, return True
    return 1,0,0,0,0

update_the_dt()

To prevent users from encountering problems during the process of setting dt, the program will automatically adjust dt based on the simulation results.

If negative particle distribution occurs during the calculation process, the program will return to the distribution before time_stride_back and decrease dt.

If there is no negative particle distribution in 100 time steps of the calculation, the program will increase dt to reduce computation time.

self.change_index = self.change_index + 1
if any(whether_terminate) == 0: 
    self.change_index = 0
    self.change_time(self.dt_upper_limit, self.dt_lower_limit, 0, 1)
    print("Since the f < 0, we reduce dt. The dt is: ",self.global_dt)

    self.back_to_previous = 1
    del self.dt_list[-self.time_stride_back:]

else:  #exchange bundaries when the distributions are legel 
    self.back_to_previous = 0
    # exchange the boundaries after evaluation
    if self.number_regions > 1:
        self.exchange_boundaries()

    # exchange EM fields for Vlasov term
    if processes['VT']>0.5:
        self.exchange_EM_fields()   

    if self.change_index == 100:
        self.change_index = 0
        self.change_time(self.dt_upper_limit, self.dt_lower_limit, 1, 0)
        if abs(self.global_dt - self.dt_upper_limit) > 10**(-13):
            print("We have increased dt to inhence performance. The dt is: ",self.global_dt)
        
self.dt_list.append(self.global_dt)

change_time()

The program primarily changes the value of dt based on the input parameters. The input parameters for the program are as follows:

up_line: Upper limit of dt; down_line: Lower limit of dt

The variables “up” and “down” serve as indicators for whether dt should be increased or decreased. When up=1, it indicates that dt should be increased, and when down=1, it indicates that dt should be decreased.

def change_time(self,up_line, down_line, up, down):    
    if up == 1:
        self.global_dt = self.global_dt*10
    if down == 1:
        self.global_dt = self.global_dt/10
    if self.global_dt < down_line:
        raise AssertionError("The dt has reached the lower limit! Try use different configuration, e.g. d_sigma")
    if self.global_dt > up_line:
        self.global_dt = self.global_dt/10

results matching ""

    No results matching ""