Example #1
0
    def compute(self, system: System, binning: Binning, neighbor: Neighbor, fill: bool) -> None:
        self.x = system.x
        self.f = system.f
        self.id = system.id
        self.type = system.type
        self.N_local = system.N_local

        self.step = self.step_i
        self.bin_count = binning.bincount
        self.bin_offsets = binning.binoffsets
        self.permute_vector = binning.permute_vector

        self.nhalo = binning.nhalo
        self.nbinx = binning.nbinx
        self.nbiny = binning.nbiny
        self.nbinz = binning.nbinz

        if fill:
            self.f.fill(0)
        else:
            for i in range(self.f.x):
                for j in range(self.f.y):
                    self.f[i][j] = 0.0

        self.nbins: int = self.nbinx * self.nbiny * self.nbinz

        self.parallel_for = True
        pk.execute(self)

        self.step_i += 1
        self.x = t_x()
        self.type = t_type()
        self.f = t_f()
Example #2
0
    def compute_energy(self, system: System, binning: Binning, neighbor: Neighbor) -> float:
        self.x = system.x
        self.id = system.id
        self.type = system.type
        self.N_local = system.N_local

        self.bin_count = binning.bincount
        self.bin_offsets = binning.binoffsets
        self.permute_vector = binning.permute_vector

        self.nhalo = binning.nhalo
        self.nbinx = binning.nbinx
        self.nbiny = binning.nbiny
        self.nbinz = binning.nbinz

        self.nbins: int = self.nbinx * self.nbiny * self.nbinz

        self.parallel_for = False
        pk.execute(self, dependencies=[t_scalar3])

        self.x = t_x()
        self.type = t_type()
        self.f = t_f()

        return self.PE
Example #3
0
    def __init__(self, comm: Comm):
        self.comm = comm
        self.v: pk.View2D[pk.double] = t_v(0, 3)
        self.mass: pk.View1D[pk.double] = t_mass(0)
        self.type: pk.View1D[pk.int32] = t_type(0)
        self.N_local: int = 0

        # Reduction result
        self.T: float = 0.0
Example #4
0
    def __init__(self, s: System, comm_depth: float):
        super().__init__(s, comm_depth)

        # copied from System
        self.domain_x: float = 0.0
        self.domain_y: float = 0.0
        self.domain_z: float = 0.0

        self.sub_domain_x: float = 0.0
        self.sub_domain_y: float = 0.0
        self.sub_domain_z: float = 0.0

        self.sub_domain_hi_x: float = 0.0
        self.sub_domain_hi_y: float = 0.0
        self.sub_domain_hi_z: float = 0.0

        self.sub_domain_lo_x: float = 0.0
        self.sub_domain_lo_y: float = 0.0
        self.sub_domain_lo_z: float = 0.0

        self.x: pk.View2D[pk.double] = t_x(0, 3)
        self.v: pk.View2D[pk.double] = t_v(0, 3)
        self.f: pk.View2D[pk.double] = t_f(0, 3)
        self.id: pk.View1D[pk.int32] = t_id(0)
        self.type: pk.View1D[pk.int32] = t_type(0)
        self.q: pk.View1D[pk.double] = t_q(0)
        self.mass: pk.View1D[pk.double] = t_mass(0)

        # copied from Comm
        self.comm_depth: float = comm_depth

        print("CommSerial")
        self.pack_count: pk.View1D[pk.int32] = pk.View([1], pk.int32)
        self.pack_indicies_all: pk.View2D[pk.int32] = pk.View(
            [6, 0], pk.int32, layout=pk.Layout.LayoutRight)

        self.num_ghost: List[int] = [0] * 6
        self.ghost_offsets: List[int] = [0] * 6

        self.phase: int = 0

        # Assign
        self.workunit_id: int = 0

        # Needed for translation to succeed
        self.N_local: int = 0
        self.nparticles: int = 0
        self.update_threads: int = 0
        self.force_threads: int = 0
        self.N_ghost: int = 0

        self.pack_indicies: pk.View1D[pk.int32] = self.pack_indicies_all[0, :]
        self.ghost_offsets: pk.View1D[pk.int32] = pk.View([6], pk.int32)
Example #5
0
    def compute(self, system: System) -> float:
        self.v = system.v
        self.mass = system.mass
        self.type = system.type

        self.N_local = system.N_local
        pk.execute(pk.ExecutionSpace.Default, self)

        self.v = t_v(0, 3)
        self.mass = t_mass(0)
        self.type = t_type(0)

        factor: float = 0.5 * system.mvv2e

        self.comm.reduce_float(self.KE, 1)
        return self.KE * factor
Example #6
0
    def __init__(self):
        self.N: int = 0
        self.N_max: int = 0
        self.N_local: int = 0
        self.N_ghost: int = 0
        self.ntypes: int = 1

        self.x = t_x(0, 3, pk.double)
        self.v = t_v(0, 3, pk.double)
        self.f = t_f(0, 3, pk.double)
        self.id = t_id(0, pk.int32)
        self.type = t_type(0, pk.int32)
        self.q = t_q(0, pk.double)
        self.mass = t_mass(0, pk.double)

        self.domain_x: float = 0.0
        self.domain_y: float = 0.0
        self.domain_z: float = 0.0

        self.sub_domain_x: float = 0.0
        self.sub_domain_y: float = 0.0
        self.sub_domain_z: float = 0.0

        self.sub_domain_hi_x: float = 0.0
        self.sub_domain_hi_y: float = 0.0
        self.sub_domain_hi_z: float = 0.0

        self.sub_domain_lo_x: float = 0.0
        self.sub_domain_lo_y: float = 0.0
        self.sub_domain_lo_z: float = 0.0

        self.mvv2e: float = 0.0
        self.boltz: float = 0.0
        self.dt: float = 0.0

        self.do_print: bool = True
        self.print_lammps: bool = False