示例#1
0
def get_lifetime():
    """
    Calculate the lifetime of species.
    """
    rxns = []
    lines = parse_rxn()
    for i in lines:
        a = Rxn(i)
        rxns.append(a)
    sim_time = rxns[-1].nstep
    
    mols = []
    lines = parse_molid()
    for i in lines:
        a = Mol(i)
        mols.append(a)

    for i in range(len(mols)):
        id = mols[i].id
        start = 0
        end = sim_time
        for j in range(len(rxns)):
            #print id, rxns[j].proid
            if id in rxns[j].proid:
                start = rxns[j].nstep
            if id in rxns[j].reacid:
                end = rxns[j].nstep
        mols[i].lifetime = end - start
    output_molid_ext(mols)
示例#2
0
    def get_lifetime():
        """
        Calculate the lifetime of species.
        """
        sim_time = self.rxns[-1].nstep

        mols = []
        lines = parse_molid()
        for i in lines:
            a = Mol(i)
            mols.append(a)

        for i in range(len(mols)):
            id = mols[i].id
            start = 0
            end = sim_time
            for j in range(len(self.rxns)):
                #print id, rxns[j].proid
                if id in self.rxns[j].proid:
                    start = self.rxns[j].nstep
                if id in self.rxns[j].reacid:
                    end = self.rxns[j].nstep
            mols[i].lifetime = end - start
        output_molid_ext(mols)
示例#3
0
    def get_initial_reactants(self, tag):
        """
        Get all the possible initial reactants for any specified
        reaction (tag)
        """

        # get reaction mol id
        nstep = int(tag.split("_")[0])
        id = int(tag.split("_")[1])
        for i in self.rxns:
            if i.nstep == nstep and i.id == id:
                reac = i.reacid

        # reaction species
        print "-" * 72
        print "reaction species are: "
        for i in reac:
            print i
        print "-" * 72

        # read molid file
        mols = []
        lines = parse_molid()
        for i in lines:
            a = Mol(i)
            mols.append(a)

        # get atoms
        atoms = []
        reac_atoms = []
        for i in reac:
            for j in mols[i - 1].atoms:
                atoms.append(j)
                reac_atoms.append(j)

        max_mol = max(reac)

        # @note: need to be a parameter
        n_inital = 24

        print "reactions species from begining are: "
        for i in range(n_inital):
            n_match = 0
            for j in reac_atoms:
                if j in mols[i].atoms:
                    n_match += 1
            m = n_match * 1.0 / mols[i].natom
            if m > 0:
                print mols[i].id, m
        print "-" * 72

        print "intermidate mol id involved are: "
        for i in range(max_mol, n_inital, -1):
            flag = 0
            for j in reac_atoms:
                if j in mols[i].atoms:
                    print i
                    break
        print "-" * 72

        for i in range(max_mol, n_inital, -1):
            flag = 0
            for j in atoms:
                if j in mols[i].atoms:
                    flag = 1
                    break
            if flag:
                for k in mols[i].atoms:
                    if k not in atoms:
                        atoms.append(k)

        print "All possible species involved from begining are: "
        initial_mols = []
        for i in range(n_inital):
            n_match = 0
            for j in atoms:
                if j in mols[i].atoms:
                    n_match += 1
            m = n_match * 1.0 / mols[i].natom
            if m > 0:
                print mols[i].id, m
示例#4
0
    def get_initial_reactants(self, tag):
        """
        Get all the possible initial reactants for any specified
        reaction (tag)
        """

        # get reaction mol id
        nstep = int(tag.split("_")[0])
        id = int(tag.split("_")[1])
        for i in self.rxns:
            if i.nstep == nstep and i.id == id:
                reac = i.reacid

        # reaction species
        print "-"*72
        print "reaction species are: "
        for i in reac:
            print i
        print "-"*72

        # read molid file
        mols = []
        lines = parse_molid()
        for i in lines:
            a = Mol(i)
            mols.append(a)
        
        # get atoms
        atoms = []
        reac_atoms = []
        for i in reac:
            for j in mols[i-1].atoms:
                atoms.append(j)
                reac_atoms.append(j)
        
        max_mol = max(reac)

        # @note: need to be a parameter
        n_inital = 24

        print "reactions species from begining are: "
        for i in range(n_inital):
            n_match = 0
            for j in reac_atoms:
                if j in mols[i].atoms:
                    n_match += 1
            m = n_match * 1.0 / mols[i].natom
            if m > 0:
                print mols[i].id, m
        print "-"*72
    
        print "intermidate mol id involved are: "
        for i in range(max_mol, n_inital, -1):
            flag = 0
            for j in reac_atoms:
                if j in mols[i].atoms:
                    print i
                    break
        print "-"*72

        for i in range(max_mol, n_inital, -1):
            flag = 0
            for j in atoms:
                if j in mols[i].atoms:
                    flag = 1
                    break
            if flag:
                for k in mols[i].atoms:
                    if k not in atoms:
                        atoms.append(k)
        
        print "All possible species involved from begining are: "
        initial_mols = []
        for i in range(n_inital):
            n_match = 0
            for j in atoms:
                if j in mols[i].atoms:
                    n_match += 1
            m = n_match * 1.0 / mols[i].natom
            if m > 0:
                print mols[i].id, m