-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoicepost.py
executable file
·95 lines (83 loc) · 3.11 KB
/
autoicepost.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 05 17:48:26 2015
@author: glbjch
"""
from t2data import *
from t2grids import *
from t2listing import *
import os
import pytoughgrav as ptg
import matplotlib.pyplot as plt
import numpy as np
import time
import ice_pytough as ipt
import argparse
#%% set up
t0=tinit=time.clock()
plt.close('all')
parser = argparse.ArgumentParser(description='Prepare perturbation model')
parser.add_argument('-b','--base', help='basemodel name',required=True)
parser.add_argument('-l','--location', help='location',required=False, default='.')
parser.add_argument('-e','--eos',help='eos',required=False,default=3)
parser.add_argument('-r','--radial_model',help='set if radial model',action='store_true')
args = parser.parse_args()
os.chdir(args.location)
if args.radial_model:
radial=True
else:
radial=False
mod=args.base # define model name
eos=args.eos
read=True ########### I N P U T #########################
readgeo=True ########### I N P U T #########################
geo_fname='grd.dat'
readdat=True ########### I N P U T #########################
dat_fname='flow2.inp'
readresults=True ########### I N P U T #########################
results_fname='flow2.out'
readflow=True ########### I N P U T #########################
#flowH_fname='results/FLOH.pkl'
#readflowF=True ########### I N P U T #########################
#flowF_fname='results/FLOLIQ.pkl'
save=True ########### I N P U T #########################
savevtk=True ########### I N P U T #########################
if eos==1:
flows={'FHEAT':{},'FLO(AQ.)':{},'FLO(GAS)':{}}
else: flows={'FLOH':{},'FLO(LIQ.)':{},'FLO(GAS)':{}}
print 'model=',mod
#os.chdir('C:/Users/glbjch/Local Documents/Work/Modelling/Cotapaxi/'+mod)
if not os.path.exists('results'):
os.makedirs('results')
if read:
if readgeo is True:
print 'Reading geometry from '+ geo_fname
geo=mulgrid(geo_fname)
geo.radial=False # set flag that geometry is not yet radial.
if readdat is True:
print 'Reading input data from '+ dat_fname
dat=t2data(dat_fname)
if readresults is True:
print 'Reading results from '+ results_fname
results=t2listing(results_fname)
if readflow is True:
if os.path.isfile('results/time.pkl'):
times=ptg.load_obj('results/time.pkl')
else:
print('CANT READ time FILE ......Continuing with times={}')
times={}
for flow in flows.keys():
flow_fname='results/'+flow+'.pkl'
if os.path.isfile(flow_fname):
print 'Reading saturation data from '+ flow_fname
flows[flow]=ptg.load_obj(flow_fname)
else:
print('CANT READ flow FILE ('+flow_fname+'......Continuing with flows['+flow+']={}')
flows[flow]={}
else:
print('Not reading '+flow+'.pkl.flows['+flow+']={}')
flows[flow]={}
t1=time.clock()
print 'time to read=',(t1-t0)
ipt.icepost(mod, geom_data=geo,tough2_input=dat, radial=radial, results=results, times=times, save=save, savevtk=savevtk,flows=flows)
print 'time to run =', time.clock()-tinit