Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from io import StringIO 

2from ase.io import read 

3from ase.utils import reader 

4 

5# Made from NWChem interface 

6 

7 

8@reader 

9def read_geom_orcainp(fd): 

10 """Method to read geometry from an ORCA input file.""" 

11 lines = fd.readlines() 

12 

13 # Find geometry region of input file. 

14 stopline = 0 

15 for index, line in enumerate(lines): 

16 if line[1:].startswith('xyz '): 

17 startline = index + 1 

18 stopline = -1 

19 elif (line.startswith('end') and stopline == -1): 

20 stopline = index 

21 elif (line.startswith('*') and stopline == -1): 

22 stopline = index 

23 # Format and send to read_xyz. 

24 xyz_text = '%i\n' % (stopline - startline) 

25 xyz_text += ' geometry\n' 

26 for line in lines[startline:stopline]: 

27 xyz_text += line 

28 atoms = read(StringIO(xyz_text), format='xyz') 

29 atoms.set_cell((0., 0., 0.)) # no unit cell defined 

30 

31 return atoms 

32 

33 

34def write_orca(atoms, **params): 

35 """Function to write ORCA input file 

36 """ 

37 charge = params['charge'] 

38 mult = params['mult'] 

39 label = params['label'] 

40 

41 if 'pcpot' in params.keys(): 

42 pcpot = params['pcpot'] 

43 pcstring = '% pointcharges \"' +\ 

44 label + '.pc\"\n\n' 

45 params['orcablocks'] += pcstring 

46 pcpot.write_mmcharges(label) 

47 

48 with open(label + '.inp', 'w') as fd: 

49 fd.write("! engrad %s \n" % params['orcasimpleinput']) 

50 fd.write("%s \n" % params['orcablocks']) 

51 

52 fd.write('*xyz') 

53 fd.write(" %d" % charge) 

54 fd.write(" %d \n" % mult) 

55 for atom in atoms: 

56 if atom.tag == 71: # 71 is ascii G (Ghost) 

57 symbol = atom.symbol + ' : ' 

58 else: 

59 symbol = atom.symbol + ' ' 

60 fd.write(symbol + 

61 str(atom.position[0]) + ' ' + 

62 str(atom.position[1]) + ' ' + 

63 str(atom.position[2]) + '\n') 

64 fd.write('*\n')