Example #1
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 #2
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 #3
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 #4
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
Example #5
0
    def check_lammps_command(self, line: int) -> None:
        known: bool = False

        if self.input_data.words[line][0] == "":
            known = True

        command: str = self.input_data.words[line][0]

        if "#" in command:
            known = True

        if command == "variable":
            if self.system.do_print:
                print("LAMMPS-Command:"
                      " 'variable' keyword is not supported in ExaMiniMD")

        if command == "units":
            unit: str = self.input_data.words[line][1]
            if unit == "metal":
                known = True
                self.units = Units.UNITS_METAL.value
                self.system.boltz = 8.617343e-5
                self.system.mvv2e = 1.0364269e-4
                self.system.dt = 0.001

            elif unit == "real":
                known = True
                self.units = Units.UNITS_REAL.value
                self.system.boltz = 0.0019872067
                self.system.mvv2e = 48.88821291 * 48.88821291

                if not self.timestepflag:
                    self.system.dt = 1.0

            elif unit == "lj":
                known = True
                self.units = Units.UNITS_LJ.value
                self.system.boltz = 1.0
                self.system.mvv2e = 1.0

                if not self.timestepflag:
                    self.system.dt = 0.005

            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'units' command only supports"
                          " 'real' and 'lj' in ExaMiniMD")

        if command == "atom_style":
            style: str = self.input_data.words[line][1]
            if style == "atomic":
                known = True
            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'atom_style' command only"
                          " supports 'atomic' in ExaMiniMD")

        if command == "lattice":
            lattice: str = self.input_data.words[line][1]
            if lattice == "sc":
                known = True
                self.lattice_style = LatticeType.LATTICE_SC.value
                self.lattice_constant = float(self.input_data.words[line][2])

            elif lattice == "fcc":
                known = True
                self.lattice_style = LatticeType.LATTICE_FCC.value
                self.lattice_constant = (
                    4.0 / float(self.input_data.words[line][2]))**(1.0 / 3.0)

            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'lattice' command only supports"
                          " 'sc' and 'fcc' in ExaMiniMD")

            if self.input_data.words[line][3] == "origin":
                self.lattice_offset_x = float(self.input_data.words[line][4])
                self.lattice_offset_y = float(self.input_data.words[line][5])
                self.lattice_offset_z = float(self.input_data.words[line][6])

        if command == "region":
            region: str = self.input_data.words[line][2]
            if region == "block":
                known = True
                box: List[int] = [0] * 6
                box[0] = int(self.input_data.words[line][3])
                box[1] = int(self.input_data.words[line][4])
                box[2] = int(self.input_data.words[line][5])
                box[3] = int(self.input_data.words[line][6])
                box[4] = int(self.input_data.words[line][7])
                box[5] = int(self.input_data.words[line][8])

                if box[0] != 0 or box[2] != 0 or box[4] != 0:
                    if self.system.do_print:
                        print("Error: LAMMPS-Command: region only allows for"
                              " boxes with 0,0,0 offset")

                self.lattice_nx = box[1]
                self.lattice_ny = box[3]
                self.lattice_nz = box[5]

            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'region' command only supports"
                          " 'block' option in ExaMiniMD")

        if command == "create_box":
            known = True
            self.system.ntypes = int(self.input_data.words[line][1])
            self.system.mass = t_mass(self.system.ntypes)

        if command == "create_atoms":
            known = True

        if command == "mass":
            known = True
            mass_type: int = int(self.input_data.words[line][1]) - 1
            mass: float = float(self.input_data.words[line][2])
            self.system.mass[mass_type] = mass

        if command == "pair_style":
            pair_style: str = self.input_data.words[line][1]
            if pair_style == "lj/cut/idial":
                known = True
                self.force_type = ForceType.FORCE_LJ_IDIAL.value
                self.force_cutoff = float(self.input_data.words[line][2])
                self.force_line = line

            elif pair_style == "lj/cut":
                known = True
                self.force_type = ForceType.FORCE_LJ.value
                self.force_cutoff = float(self.input_data.words[line][2])
                self.force_line = line

            if pair_style == "snap":
                known = True
                self.force_type = ForceType.FORCE_SNAP.value
                self.force_cutoff = 4.73442
                self.force_line = line

                if self.system.do_print and not known:
                    print("LAMMPS-Command: 'pair_style' command only supports"
                          " 'lj/cut', 'lj/cut/idial', and 'snap' style"
                          " in ExaMiniMD")

        if command == "pair_coeff":
            known = True
            n_coeff_lines: int = self.force_coeff_lines.extent(0)
            self.force_coeff_lines.resize(0, n_coeff_lines + 1)
            self.force_coeff_lines[n_coeff_lines] = line
            n_coeff_lines += 1

        if command == "velocity":
            known = True
            if self.input_data.words[line][1] != "all":
                if self.system.do_print:
                    print("Error: LAMMPS-Command: 'velocity' command can only"
                          " be applied to 'all'")

            if self.input_data.words[line][2] != "create":
                if self.system.do_print:
                    print("Error: LAMMPS-Command: 'velocity' command can only"
                          " be used with option 'create'")

            self.temperature_target = float(self.input_data.words[line][3])
            self.temperature_seed = int(self.input_data.words[line][4])

        if command == "neighbor":
            known = True
            self.neighbor_skin = float(self.input_data.words[line][1])

        if command == "neigh_modify":
            known = True
            for i in range(1, self.input_data.words_per_line - 1):
                if self.input_data.words[line][i] == "every":
                    self.comm_exchange_rate = int(
                        self.input_data.words[line][i + 1])

        if command == "fix":
            if self.input_data.words[line][3] == "nve":
                known = True
                self.integrator_type = IntegratorType.INTEGRATOR_NVE.value

            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'fix' command only supports"
                          " 'nve' style in ExaMiniMD")

        if command == "run":
            known = True
            self.nsteps = int(self.input_data.words[line][1])

        if command == "thermo":
            known = True
            self.thermo_rate = int(self.input_data.words[line][1])

        if command == "timestep":
            known = True
            self.system.dt = float(self.input_data.words[line][1])
            self.timestepflag = True

        if command == "newton":
            known = True
            newton: str = self.input_data.words[line][1]
            if newton == "on":
                self.comm_newton = 1

            elif newton == "off":
                self.comm_newton = 0

            else:
                if self.system.do_print:
                    print("LAMMPS-Command: 'newton' must be followed by"
                          " 'on' or 'off'")

        if command == "":
            known = True

        if not known and self.system.do_print:
            print("ERROR: unknown keyword")
            self.input_data.print_line(line)