106 lines
3.3 KiB
Python
Executable file
106 lines
3.3 KiB
Python
Executable file
#!/usr/bin/python
|
|
#
|
|
|
|
import os, sys
|
|
|
|
import shutil
|
|
|
|
import csv
|
|
|
|
import subprocess as sp
|
|
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("transport_file", help="directory where dummy OpenFOAM cases for test are created")
|
|
args = parser.parse_args()
|
|
|
|
transport_file = args.transport_file
|
|
|
|
|
|
charged_file = "./charged-Prager.txt"
|
|
neutral_file = "./neutral-Prager.txt"
|
|
alpha_file = "./alpha-Han.txt"
|
|
|
|
FNULL = open(os.devnull, 'w')
|
|
|
|
def paramEntry (name, param):
|
|
return "{}.transport.{}".format(name, param)
|
|
|
|
with open(charged_file, 'r') as cfile:
|
|
|
|
entries = "rotationalRelaxation dipolePolarizability".split()
|
|
for row in cfile:
|
|
name, n, alpha, c6, zrot = row.split()
|
|
# print "\t".join([name, n, alpha, c6, zrot ])
|
|
|
|
call_state = sp.call(("foamDictionary -entry ").split() + [name, transport_file] , stdout=FNULL, stderr=FNULL)
|
|
|
|
val = [zrot, alpha]
|
|
|
|
if call_state == 0:
|
|
print "touching ", name, "..."
|
|
for k, v in zip(entries, val):
|
|
# print name, k, v
|
|
sp.check_call(["foamDictionary", "-entry", paramEntry(name,k), "-set", v, transport_file], stdout=FNULL, stderr=FNULL)
|
|
|
|
with open(neutral_file, 'r') as cfile:
|
|
|
|
entries = "rotationalRelaxation wellDepth diameter dipoleMoment dipolePolarizability".split()
|
|
|
|
for row in cfile:
|
|
name, ek, sigma, q, alpha, c6, zrot, alphaQ = row.split()
|
|
# print "\t".join([name, ek, sigma, q, alpha, c6, zrot, alphaQ])
|
|
|
|
call_state = sp.call(("foamDictionary -entry ").split() + [name, transport_file] , stdout=FNULL, stderr=FNULL)
|
|
|
|
val = [zrot, ek, sigma, q, alpha]
|
|
|
|
if call_state == 0:
|
|
print "touching ", name, "..."
|
|
for k, v in zip(entries, val):
|
|
# print name, k, v
|
|
sp.check_call(["foamDictionary", "-entry", paramEntry(name,k), "-set", v, transport_file], stdout=FNULL, stderr=FNULL)
|
|
else:
|
|
print "passing nonexistent ", name, "..."
|
|
|
|
|
|
with open(alpha_file, 'r') as cfile:
|
|
|
|
for row in cfile:
|
|
name, a, c, h, o, n, i, hap, ha = row.split()
|
|
# print "\t".join((name, a, c, h, o, n, i, hap, ha))
|
|
|
|
call_state = sp.call(("foamDictionary -entry ").split() + [name, transport_file] , stdout=FNULL, stderr=FNULL)
|
|
|
|
if call_state == 0:
|
|
print "touching ", name, "..."
|
|
|
|
sp.check_call(["foamDictionary", "-entry", paramEntry(name,"dipolePolarizability"), "-set", a, transport_file], stdout=FNULL, stderr=FNULL)
|
|
else:
|
|
print "passing nonexistent ", name, "..."
|
|
|
|
|
|
'''
|
|
record = { k.split()[0]:v for k, v in zip(header, row)}
|
|
|
|
case = os.path.join(cases_dir, record['z'])
|
|
case_ic = os.path.join(case, "constant/initialConditions")
|
|
|
|
shutil.copytree("onedim", case)
|
|
# sp.check_call(("echo foamDictionary -entry fractions -set '{}' cases2/"+record['z']+"/constant/initialConditions").split())
|
|
|
|
sp.check_call(("foamDictionary -entry Tl -set ").split() + [record["T"] , case_ic], stdout=FNULL)
|
|
|
|
for s in species:
|
|
sp.check_call(("foamDictionary -entry fractions." + s + " -set ").split() + [record[s] , case_ic], stdout=FNULL)
|
|
|
|
error = sp.call(("./canteraTest -relTol 0.06 -case " + case).split())
|
|
|
|
error_cases.append(error)
|
|
|
|
print "Errorneous cases"
|
|
print error_cases
|
|
|
|
sys.exit(sum(error_cases))
|
|
'''
|