Exemple #1
0
    def _read_energies(self):
        oniom_loc_bytes = self.bytedict['ONIOM: calculating energy.']
        scf_loc_bytes = self.bytedict['SCF Done:']

        ONIOM_extrapol = []
        ONIOM_model_high = []
        ONIOM_model_low = []
        ONIOM_real_low = []
        ONIOM_lowlayer_low = []
        SCF_energy = []

        f = open(self.name)
        for complete_opt in oniom_loc_bytes:
            ONIOM_model_high.append([])
            ONIOM_model_low.append([])
            ONIOM_real_low.append([])
            ONIOM_lowlayer_low.append([])
            ONIOM_extrapol.append([])
            for location_byte in complete_opt:
                f.seek(location_byte)
                f.readline()  # discard this line
                model_low = misc.starfloat(
                    f.readline().split('low   system:  model energy:')[1])
                ONIOM_model_low[-1].append(model_low)

                model_high = misc.starfloat(
                    f.readline().split('high  system:  model energy:')[1])
                ONIOM_model_high[-1].append(model_high)

                real_low = misc.starfloat(
                    f.readline().split('low   system:  real  energy:')[1])
                ONIOM_real_low[-1].append(real_low)

                extrapol = misc.starfloat(
                    f.readline().split('extrapolated energy =')[1])
                ONIOM_extrapol[-1].append(extrapol)

                ONIOM_lowlayer_low[-1].append(real_low - model_low)
        for complete_opt in scf_loc_bytes:
            SCF_energy.append([])
            for location_byte in complete_opt:
                f.seek(location_byte)
                SCF_energy[-1].append(
                    float(f.readline().split('=')[1].split()[0]))

        energies = {}
        energies['ONIOM_extrapol'] = ONIOM_extrapol
        energies['ONIOM_model_high'] = ONIOM_model_high
        energies['ONIOM_lowlayer_low'] = ONIOM_lowlayer_low
        energies['SCF_energy'] = SCF_energy
        return energies
Exemple #2
0
    def read_converged(self, byte):

        OFF = 60
        LINE_OFF = 56
        LABEL_START = 1
        VALUE_START = 26
        THRESH_START = 39
        NCHARS_LABEL = 20
        NCHARS_FLOAT = 8
        stop_label = 'Predicted change in '
        short_labels = {
            'Maximum Force       ': 'Max F',
            'RMS     Force       ': 'rms F',
            'Maximum Displacement': 'Max D',
            'RMS     Displacement': 'rms D',
            'Maximum MM Force    ': 'MaxMM',
            'RMS     MM Force    ': 'rmsMM'
        }

        labels = []
        values = []
        thresholds = []

        # correct byte
        f = open(self.name)
        f.seek(byte - 1)
        if f.read(1) != '\n':
            byte = byte - 1
            stderr.write('WARTING: grep -b 1 byte ahead\n')

        for i in range(7):
            off = byte + OFF + i * LINE_OFF
            f.seek(off + LABEL_START)
            label = f.read(NCHARS_LABEL)
            if label == stop_label:
                f.close()
                return (labels, values, thresholds)
            labels.append(short_labels[label])
            f.seek(off + VALUE_START)
            values.append(misc.starfloat(f.read(NCHARS_FLOAT)))
            f.seek(off + THRESH_START)
            thresholds.append(misc.starfloat(f.read(NCHARS_FLOAT)))

        # if here, stop_label not found
        f.close()
        error_msg = 'Expected %s after Converged section' % stop_label
        print(labels, values, thresholds)
        raise RuntimeError(error_msg)
    def read_converged(self, byte):

        OFF = 60
        LINE_OFF = 56 
        LABEL_START = 1
        VALUE_START = 26 
        THRESH_START = 39 
        NCHARS_LABEL = 20
        NCHARS_FLOAT = 8
        stop_label = 'Predicted change in '
        short_labels = {
            'Maximum Force       ': 'Max F',
            'RMS     Force       ': 'rms F',
            'Maximum Displacement': 'Max D',
            'RMS     Displacement': 'rms D',
            'Maximum MM Force    ': 'MaxMM',
            'RMS     MM Force    ': 'rmsMM'
        }

        labels = []
        values = []
        thresholds = []

        # correct byte
        f = open(self.name)
        f.seek(byte-1)
        if f.read(1) != '\n':
            byte = byte - 1
            stderr.write('WARTING: grep -b 1 byte ahead\n')

        for i in range(7):
            off = byte + OFF + i*LINE_OFF
            f.seek(off + LABEL_START)
            label = f.read(NCHARS_LABEL)
            if label == stop_label:
                f.close()
                return (labels, values, thresholds)
            labels.append(short_labels[label])
            f.seek(off + VALUE_START)
            values.append(misc.starfloat(f.read(NCHARS_FLOAT)))
            f.seek(off + THRESH_START)
            thresholds.append(misc.starfloat(f.read(NCHARS_FLOAT)))

        # if here, stop_label not found
        f.close()
        error_msg = 'Expected %s after Converged section' % stop_label
        print(labels, values, thresholds)
        raise RuntimeError(error_msg)
    def _read_energies(self):
        oniom_loc_bytes = self.bytedict['ONIOM: calculating energy.']
        scf_loc_bytes   = self.bytedict['SCF Done:']

        ONIOM_extrapol  = []
        ONIOM_model_high= []
        ONIOM_model_low = []
        ONIOM_real_low  = []
        ONIOM_lowlayer_low = []
        SCF_energy = []

        f = open(self.name)
        for complete_opt in oniom_loc_bytes:
            ONIOM_model_high.append([])
            ONIOM_model_low.append([])
            ONIOM_real_low.append([])
            ONIOM_lowlayer_low.append([])
            ONIOM_extrapol.append([])
            for location_byte in complete_opt:
                f.seek(location_byte)
                f.readline() # discard this line
                model_low  = misc.starfloat(f.readline().split('low   system:  model energy:')[1])
                ONIOM_model_low[-1].append(model_low)

                model_high = misc.starfloat(f.readline().split('high  system:  model energy:')[1])
                ONIOM_model_high[-1].append(model_high)

                real_low   = misc.starfloat(f.readline().split('low   system:  real  energy:')[1])
                ONIOM_real_low[-1].append(real_low)

                extrapol   = misc.starfloat(f.readline().split('extrapolated energy =')[1])
                ONIOM_extrapol[-1].append(extrapol)
                
                ONIOM_lowlayer_low[-1].append(real_low-model_low)
        for complete_opt in scf_loc_bytes:
            SCF_energy.append([])
            for location_byte in complete_opt:
                f.seek(location_byte)
                SCF_energy[-1].append(float(f.readline().split('=')[1].split()[0]))

        energies = {}
        energies['ONIOM_extrapol'] = ONIOM_extrapol
        energies['ONIOM_model_high'] = ONIOM_model_high
        energies['ONIOM_lowlayer_low'] = ONIOM_lowlayer_low
        energies['SCF_energy'] = SCF_energy
        return energies