Ejemplo n.º 1
0
    def copy(cls, lot, options, copy_wavefunction=True):

        # Get node id for new struct
        node_id = options.get('node_id', 1)
        print(" making folder scratch/{}".format(node_id))
        os.system('mkdir -p scratch/{}'.format(node_id))

        file_options = File_Options.copy(lot.file_options)
        options['file_options'] = file_options

        if node_id != lot.node_id and copy_wavefunction:
            old_path = 'scratch/{}/orbs.archive'.format(lot.node_id)
            new_path = 'scratch/{}/orbs.archive'.format(node_id)
            cmd = 'cp -r ' + old_path + ' ' + new_path
            print(" copying scr files\n {}".format(cmd))
            os.system(cmd)
            os.system('wait')
        return cls(lot.options.copy().set_values(options))
Ejemplo n.º 2
0
    def copy(cls, lot, options, copy_wavefunction=True):

        node_id = options.get('node_id', lot.node_id)

        file_options = File_Options.copy(lot.file_options)
        options['file_options'] = file_options

        if node_id != lot.node_id and copy_wavefunction:
            if "casscf" in lot.file_options.ActiveOptions:
                old_path = 'scratch/{:03}/{}/c0.casscf'.format(
                    lot.ID, lot.node_id)
                new_path = 'scratch/{:03}/{}/c0.casscf'.format(lot.ID, node_id)
                copy_file(old_path, new_path)
            else:
                if lot.unrestricted:
                    old_path = 'scratch/{:03}/{}/ca0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    if os.path.isfile(old_path):
                        copy_file(old_path, new_path)
                    else:
                        print(" no file to copy")
                    old_path = 'scratch/{:03}/{}/cb0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    if os.path.isfile(old_path):
                        copy_file(old_path, new_path)
                    else:
                        print(" no file to copy")
                else:
                    old_path = 'scratch/{:03}/{}/c0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    if os.path.isfile(old_path):
                        copy_file(old_path, new_path)
                    else:
                        print(" no file to copy")
            # cmd = 'cp -r ' + old_path +' ' + new_path
            # print(" copying scr files\n {}".format(cmd))
            # os.system(cmd)
            # os.system('wait')
        return cls(lot.options.copy().set_values(options))
Ejemplo n.º 3
0
    def copy(cls, lot, options, copy_wavefunction=True):

        node_id = options.get('node_id', 1)

        print(" making folder scratch/{}".format(node_id))
        os.system('mkdir -p scratch/{}'.format(node_id))

        file_options = File_Options.copy(lot.file_options)
        options['file_options'] = file_options

        if node_id != lot.node_id and copy_wavefunction:
            if "casscf" in lot.file_options.ActiveOptions:
                old_path = 'scratch/{}/c0.casscf'.format(lot.node_id)
                new_path = 'scratch/{}/'.format(node_id)
            else:
                old_path = 'scratch/{}/c0'.format(lot.node_id)
                new_path = 'scratch/{}/'.format(node_id)
            cmd = 'cp -r ' + old_path + ' ' + new_path
            print(" copying scr files\n {}".format(cmd))
            os.system(cmd)
            os.system('wait')
        return cls(lot.options.copy().set_values(options))
Ejemplo n.º 4
0
    def copy(cls, lot, options, copy_wavefunction=True):

        node_id = options.get('node_id', lot.node_id)

        file_options = File_Options.copy(lot.file_options)
        options['file_options'] = file_options

        if node_id != lot.node_id and copy_wavefunction:
            if "casscf" in lot.file_options.ActiveOptions:
                old_path = 'scratch/{:03}/{}/c0.casscf'.format(
                    lot.ID, lot.node_id)
                new_path = 'scratch/{:03}/{}/c0.casscf'.format(lot.ID, node_id)
                copy_file(old_path, new_path)
            else:
                use_alpha = False
                for state in lot.states:
                    if state[0] == 2:
                        use_alpha = True
                if use_alpha:
                    old_path = 'scratch/{:03}/{}/ca0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    copy_file(old_path, new_path)
                    old_path = 'scratch/{:03}/{}/cb0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    copy_file(old_path, new_path)
                else:
                    old_path = 'scratch/{:03}/{}/c0'.format(
                        lot.ID, lot.node_id)
                    new_path = 'scratch/{:03}/{}/'.format(lot.ID, node_id)
                    copy_file(old_path, new_path)
            #cmd = 'cp -r ' + old_path +' ' + new_path
            #print(" copying scr files\n {}".format(cmd))
            #os.system(cmd)
            #os.system('wait')
        return cls(lot.options.copy().set_values(options))
Ejemplo n.º 5
0
    def __init__(
        self,
        options,
    ):
        """ Constructor """

        self.options = options

        # properties
        self.Energy = namedtuple('Energy', 'value unit')
        self.Gradient = namedtuple('Gradient', 'value unit')
        self.Coupling = namedtuple('Coupling', 'value unit')
        self._Energies = {}
        self._Gradients = {}
        self._Couplings = {}

        # count number of states
        singlets = self.search_tuple(self.states, 1)
        doublets = self.search_tuple(self.states, 2)
        triplets = self.search_tuple(self.states, 3)
        quartets = self.search_tuple(self.states, 4)
        quintets = self.search_tuple(self.states, 5)

        #TODO do this for all states, since it catches if states are put in lazy e.g [(1,1)]
        if singlets:
            len_singlets = max(singlets, key=lambda x: x[1])[1] + 1
        else:
            len_singlets = 0
        len_doublets = len(doublets)
        len_triplets = len(triplets)
        len_quartets = len(quartets)
        len_quintets = len(quintets)

        # DO this before fixing states if put in lazy
        if self.options['gradient_states'] == None and self.calc_grad:
            print(" Assuming gradient states are ", self.states)
            self.options['gradient_states'] = self.options['states']

        if len(
                self.states
        ) < len_singlets + len_doublets + len_triplets + len_quartets + len_quintets:
            print('fixing states to be proper length')
            tmp = []
            # TODO put in rest of fixed states
            for i in range(len_singlets):
                tmp.append((1, i))
            for i in range(len_triplets):
                tmp.append((3, i))
            self.states = tmp
            print(' New states ', self.states)

        self.geom = self.options['geom']
        if self.geom is not None:
            print(" initializing LOT from geom")
        elif self.options['fnm'] is not None:
            print(" initializing LOT from file")
            if not os.path.exists(self.options['fnm']):
                logger.error(
                    'Tried to create LOT object from a file that does not exist: %s\n'
                    % self.options['fnm'])
                raise IOError
            self.geom = manage_xyz.read_xyz(self.options['fnm'], scale=1.)
        else:
            raise RuntimeError("Need to initialize LOT object")

        # Cache some useful atributes - other useful attributes are properties
        self.currentCoords = manage_xyz.xyz_to_np(self.geom)
        self.atoms = manage_xyz.get_atoms(self.geom)
        self.ID = self.options['ID']
        self.nproc = self.options['nproc']
        self.charge = self.options['charge']
        self.node_id = self.options['node_id']
        self.lot_inp_file = self.options['lot_inp_file']

        # Bools for running
        self.hasRanForCurrentCoords = False
        self.has_nelectrons = False

        # Read file options if they exist and not already set
        if self.file_options is None:
            self.file_options = File_Options(self.lot_inp_file)

        #package  specific implementation
        #TODO MOVE to specific package !!!
        # tc cloud
        self.options['job_data']['orbfile'] = self.options['job_data'].get(
            'orbfile', '')
        # pytc? TODO
        self.options['job_data']['lot'] = self.options['job_data'].get(
            'lot', None)

        print(" making folder scratch/{:03}/{}".format(self.ID, self.node_id))
        os.system('mkdir -p scratch/{:03}/{}'.format(self.ID, self.node_id))