9
1
mirror of https://github.com/QuantumPackage/qp2.git synced 2024-11-09 15:03:37 +01:00
qp2/scripts/perturbation.py

28 lines
664 B
Python
Raw Normal View History

2020-03-17 16:39:43 +01:00
#!/usr/bin/env python3
2019-01-25 11:39:31 +01:00
import os
2019-03-20 12:43:32 +01:00
from qp_path import QP_SRC
2019-01-25 11:39:31 +01:00
2019-03-20 12:43:32 +01:00
Pert_dir = os.path.join(QP_SRC,"perturbation")
2019-01-25 11:39:31 +01:00
perturbations = []
2020-03-17 16:39:43 +01:00
for filename in [x for x in os.listdir(Pert_dir) if x.endswith(".irp.f")]:
2019-01-25 11:39:31 +01:00
2019-03-20 12:43:32 +01:00
filename = os.path.join(Pert_dir,filename)
2019-01-25 11:39:31 +01:00
file = open(filename,'r')
lines = file.readlines()
file.close()
for line in lines:
buffer = line.lower().lstrip().split()
if len(buffer) > 1:
if buffer[0] == "subroutine" and buffer[1].startswith("pt2_"):
p = (buffer[1].split('(')[0])[4:]
perturbations.append( p )
if __name__ == '__main__':
2020-03-17 16:39:43 +01:00
print('Perturbations:')
2019-01-25 11:39:31 +01:00
for k in perturbations:
2020-03-17 16:39:43 +01:00
print('* ', k)