コード例 #1
0
def test_s22():
    fragTest = Fragmentation(s22.s22)
    
    minimize = False
    #minimize = True
    print 'Relaxed:', minimize
    
    fragTest.molecules = []
    fragTest.fragments = []
    
    for moleculeName in s22.s22:
        data = s22.data[moleculeName]
        atoms = Atoms(data['symbols'], data['positions'])
        dimer1End = data['dimer atoms'][0]
        frag1Atoms = atoms.copy()[:dimer1End]
        frag2Atoms = atoms.copy()[dimer1End:]
        fragment1 = ReaxFFSystem(moleculeName + '_f1', frag1Atoms, minimize = minimize)
        fragment2 = ReaxFFSystem(moleculeName + '_f2', frag2Atoms, minimize = minimize)
        system = ReaxFFSystem(moleculeName, atoms, minimize = minimize,
                    fragment_list = [fragment1.name, fragment2.name])
        fragTest.molecules.append(system)
        fragTest.fragments += [fragment1, fragment2]
    
    fragTest.fill_data_reference(data_type='s22')
    fragTest.run(write=True)
コード例 #2
0
def testSingle(molecule): 
    #TEST fragmentation
    print "Test fragmentation with s22 set"
    fragment_names = [molecule+'_f1',molecule+'_f2']
    test_f = Fragmentation([molecule])
    
    minimize = False
    #minimize = True
    print 'Relaxed:', minimize
    
    sys = Atoms(s22_sim_data[molecule]['symbols'],
                s22_sim_data[molecule]['positions'])
        
    test_f.molecules = [ReaxFFSystem(molecule,atoms=sys,
                                    fragment_list=fragment_names, minimize=minimize)]

    n = s22_sim_data[molecule]['dimer atoms']

    atom_fragments = [ sys.copy()[range(n[0])], sys.copy()[range(n[0],n[0]+n[1])] ]
    test_f.fragments = [ ReaxFFSystem(name,atoms=a, minimize = minimize)
                         for name,a in zip(fragment_names,atom_fragments)]
        
    test_f.fill_data_reference(data_type='s22')
    test_f.run(write=True)

    print test_f.data
コード例 #3
0
ファイル: gpaw_energy.py プロジェクト: csmm/multiase
def run_s22(reload=False):
    h = 0.4
    vacuum = 2.0
    #molecules = ['Ammonia_dimer']
    molecules = s22_molecules
    test_f = Fragmentation(molecules)
    
    sys = [Atoms(s22_sim_data[molecule]['symbols'],
                 s22_sim_data[molecule]['positions'])
           for molecule in molecules]
    
    test_f.molecules = [GPAWSystems(molecule,atoms=atoms,
                                    h=h, vacuum=vacuum,
                                    fragment_list=fragment_names(molecule))
                        for molecule,atoms in zip(molecules,sys)]

    atom_fragments_1 = [ system.system.copy()[fragment_n(system.name,1)] 
                         for system in test_f.molecules]
    atom_fragments_2 = [ system.system.copy()[fragment_n(system.name,2)]
                         for system in test_f.molecules]
    
    test_f.fragments = [ GPAWSystems(name+'_f1',atoms=a,h=h, vacuum=vacuum)
                         for name,a in zip(molecules,atom_fragments_1)]
    
    test_f.fragments += [ GPAWSystems(name+'_f2',atoms=a,h=h, vacuum=vacuum)
                          for name,a in zip(molecules,atom_fragments_2)]
    
    test_f.fill_data_reference(data_type='s22')
    if reload:
        test_f.load_data('data.pkl')
        test_f.calculate_error()
        test_f.calculate_mae()
        print test_f.mae
    else:
        test_f.run(write=True)
コード例 #4
0
def testSingle(moleculeName = "Methane_dimer"): 
    #TEST fragmentation
    print "Test fragmentation with s22 set"
    
    minimize = False
    minimize = True
    print 'Relaxed:', minimize
    
    fragTest = Fragmentation([moleculeName])
    
    #atoms = s22.create_s22_system(moleculeName)
    data = s22.data[moleculeName]
    atoms = Atoms(data['symbols'], data['positions'])
    dimer1End = s22.data[moleculeName]['dimer atoms'][0]
    frag1Atoms = atoms.copy()[:dimer1End]
    frag2Atoms = atoms.copy()[dimer1End:]
    
    calculate_charges(frag1Atoms)
    calculate_charges(frag2Atoms)
    atoms.set_charges(np.append(frag1Atoms.get_charges(), frag2Atoms.get_charges()))
    
    fragment1 = CHARMMSystem(moleculeName + '_f1', frag1Atoms, minimize = minimize)
    fragment2 = CHARMMSystem(moleculeName + '_f2', frag2Atoms, minimize = minimize)
    system = CHARMMSystem(moleculeName, atoms, minimize = minimize,
                fragment_list = [fragment1.name, fragment2.name])
    fragTest.molecules = [system]
    fragTest.fragments = [fragment1, fragment2]
        
    fragTest.fill_data_reference(data_type='s22')
    fragTest.run(write=True)
    
    import ase.io    
    ase.io.write('molecule.xyz', atoms)

    print fragTest.data
コード例 #5
0
def main():
    #TEST atomization
    print "Test atomization"
    molecule_names = ['CH4']
    test = Fragmentation(molecule_names)
    test.molecules = [
        GPAWSystems(name, h=0.3, vacuum=2.0, xc='PBE')
        for name in molecule_names
    ]

    atom_names = []
    for gs in test.molecules:
        atom_names.extend(gs.system.get_chemical_symbols())

    test.fragments = [
        GPAWSystems(name, h=0.3, vacuum=2.0, xc='PBE')
        for name in set(atom_names)
    ]

    test.fill_data_reference(data_type='g22')
    test.run()

    error = 5.64039227514 - test.mae
    print 'Test error: {0} eV'.format(error)

    #TEST fragmentation
    print "Test fragmentation with s22 set"
    molecule = 'Ammonia_dimer'
    fragment_names = [molecule + '_f1', molecule + 'f2']
    test_f = Fragmentation([molecule])

    sys = Atoms(s22_sim_data[molecule]['symbols'],
                s22_sim_data[molecule]['positions'])

    test_f.molecules = [
        GPAWSystems(molecule,
                    atoms=sys,
                    h=0.4,
                    vacuum=2.0,
                    fragment_list=fragment_names)
    ]

    n = s22_sim_data[molecule]['dimer atoms']

    atom_fragments = [
        sys.copy()[range(n[0])],
        sys.copy()[range(n[0], n[0] + n[1])]
    ]
    test_f.fragments = [
        GPAWSystems(name, atoms=a, h=0.4, vacuum=2.0)
        for name, a in zip(fragment_names, atom_fragments)
    ]

    test_f.fill_data_reference(data_type='s22')
    test_f.run(write=True)

    error = 266.704827694 - test_f.mae
    print 'Test error: {0} eV'.format(error)
コード例 #6
0
ファイル: compass_energy.py プロジェクト: roguezzzzz/multiase
def test_s22():
    fragTest = Fragmentation(s22.s22)

    minimize = False
    minimize = True
    print 'Relaxed:', minimize

    fragTest.molecules = []
    fragTest.fragments = []

    testSet = [
        #'Ammonia_dimer',
        #'Water_dimer',
        #'Formic_acid_dimer',
        #'Formamide_dimer',
        #'Uracil_dimer_h-bonded',
        #'2-pyridoxine_2-aminopyridine_complex',
        #'Adenine-thymine_Watson-Crick_complex',
        'Methane_dimer',
        #'Ethene_dimer',
        'Benzene-methane_complex',
        #'Benzene_dimer_parallel_displaced',
        #'Pyrazine_dimer',
        #'Uracil_dimer_stack',
        #'Indole-benzene_complex_stack',
        #'Adenine-thymine_complex_stack',
        #'Ethene-ethyne_complex',
        #'Benzene-water_complex',
        #'Benzene-ammonia_complex',
        #'Benzene-HCN_complex',
        #'Benzene_dimer_T-shaped',
        #'Indole-benzene_T-shape_complex',
        'Phenol_dimer'
    ]

    for moleculeName in testSet:
        data = s22.data[moleculeName]
        atoms = Atoms(data['symbols'], data['positions'])
        dimer1End = data['dimer atoms'][0]
        frag1Atoms = atoms.copy()[:dimer1End]
        frag2Atoms = atoms.copy()[dimer1End:]
        fragment1 = COMPASSSystem(moleculeName + '_f1',
                                  frag1Atoms,
                                  minimize=minimize)
        fragment2 = COMPASSSystem(moleculeName + '_f2',
                                  frag2Atoms,
                                  minimize=minimize)
        system = COMPASSSystem(moleculeName,
                               atoms,
                               minimize=minimize,
                               fragment_list=[fragment1.name, fragment2.name])
        fragTest.molecules.append(system)
        fragTest.fragments += [fragment1, fragment2]

    fragTest.fill_data_reference(data_type='s22')
    fragTest.run(write=True)
コード例 #7
0
def test_s22():
    fragTest = Fragmentation(s22.s22)
    
    minimize = False
    #minimize = True
    print 'Relaxed:', minimize
    
    fragTest.molecules = []
    fragTest.fragments = []
    
    testSet = [
        'Ammonia_dimer',
        'Water_dimer',
        'Formic_acid_dimer',
        'Formamide_dimer',
        'Uracil_dimer_h-bonded',
        '2-pyridoxine_2-aminopyridine_complex',
        'Adenine-thymine_Watson-Crick_complex',
        'Methane_dimer',
        'Ethene_dimer',
        'Benzene-methane_complex',
        'Benzene_dimer_parallel_displaced',
        'Pyrazine_dimer',
        'Uracil_dimer_stack',
        'Indole-benzene_complex_stack',
        'Adenine-thymine_complex_stack',
        'Ethene-ethyne_complex',
        'Benzene-water_complex',
        'Benzene-ammonia_complex',
        'Benzene-HCN_complex',
        'Benzene_dimer_T-shaped',
        'Indole-benzene_T-shape_complex',
        'Phenol_dimer'
        ]
    
    for moleculeName in testSet:
        atoms = s22.create_s22_system(moleculeName)
        dimer1End = s22.data[moleculeName]['dimer atoms'][0]
        frag1Atoms = atoms.copy()[:dimer1End]
        frag2Atoms = atoms.copy()[dimer1End:]
        calculate_charges(frag1Atoms)
        calculate_charges(frag2Atoms)
        atoms.set_charges(np.append(frag1Atoms.get_charges(), frag2Atoms.get_charges()))
        fragment1 = CHARMMSystem(moleculeName + '_f1', frag1Atoms, minimize = minimize)
        fragment2 = CHARMMSystem(moleculeName + '_f2', frag2Atoms, minimize = minimize)
        system = CHARMMSystem(moleculeName, atoms, minimize = minimize,
                    fragment_list = [fragment1.name, fragment2.name])
        fragTest.molecules.append(system)
        fragTest.fragments += [fragment1, fragment2]
    
    fragTest.fill_data_reference(data_type='s22')
    fragTest.run(write=True)
コード例 #8
0
def run_s22(reload=False):
    h = 0.4
    vacuum = 2.0
    #molecules = ['Ammonia_dimer']
    molecules = s22_molecules
    test_f = Fragmentation(molecules)

    sys = [
        Atoms(s22_sim_data[molecule]['symbols'],
              s22_sim_data[molecule]['positions']) for molecule in molecules
    ]

    test_f.molecules = [
        GPAWSystems(molecule,
                    atoms=atoms,
                    h=h,
                    vacuum=vacuum,
                    fragment_list=fragment_names(molecule))
        for molecule, atoms in zip(molecules, sys)
    ]

    atom_fragments_1 = [
        system.system.copy()[fragment_n(system.name, 1)]
        for system in test_f.molecules
    ]
    atom_fragments_2 = [
        system.system.copy()[fragment_n(system.name, 2)]
        for system in test_f.molecules
    ]

    test_f.fragments = [
        GPAWSystems(name + '_f1', atoms=a, h=h, vacuum=vacuum)
        for name, a in zip(molecules, atom_fragments_1)
    ]

    test_f.fragments += [
        GPAWSystems(name + '_f2', atoms=a, h=h, vacuum=vacuum)
        for name, a in zip(molecules, atom_fragments_2)
    ]

    test_f.fill_data_reference(data_type='s22')
    if reload:
        test_f.load_data('data.pkl')
        test_f.calculate_error()
        test_f.calculate_mae()
        print test_f.mae
    else:
        test_f.run(write=True)
コード例 #9
0
ファイル: gpaw_energy.py プロジェクト: csmm/multiase
def main():
    #TEST atomization
    print "Test atomization"
    molecule_names = ['CH4']
    test = Fragmentation(molecule_names)
    test.molecules = [GPAWSystems(name,h=0.3,vacuum=2.0,xc='PBE')
                      for name in molecule_names]
    
    atom_names = []
    for gs in test.molecules:
        atom_names.extend(gs.system.get_chemical_symbols())
  
    test.fragments = [GPAWSystems(name,h=0.3,vacuum=2.0,xc='PBE') 
                      for name in set(atom_names)]

    test.fill_data_reference(data_type='g22')
    test.run()
    
    error = 5.64039227514 - test.mae
    print 'Test error: {0} eV'.format(error)

    #TEST fragmentation
    print "Test fragmentation with s22 set"
    molecule = 'Ammonia_dimer'
    fragment_names = [molecule+'_f1',molecule+'f2']
    test_f = Fragmentation([molecule])
    
    sys = Atoms(s22_sim_data[molecule]['symbols'],
                s22_sim_data[molecule]['positions'])
    
    test_f.molecules = [GPAWSystems(molecule,atoms=sys,
                                    h=0.4, vacuum=2.0,
                                    fragment_list=fragment_names)]

    n = s22_sim_data[molecule]['dimer atoms']

    atom_fragments = [ sys.copy()[range(n[0])], sys.copy()[range(n[0],n[0]+n[1])] ]
    test_f.fragments = [ GPAWSystems(name,atoms=a,h=0.4, vacuum=2.0)
                         for name,a in zip(fragment_names,atom_fragments)]
        
    test_f.fill_data_reference(data_type='s22')
    test_f.run(write=True)
        
    error =  266.704827694 - test_f.mae
    print 'Test error: {0} eV'.format(error)