From 2a9d2d3ad602b6610edfebecfad9d139ff805b9a Mon Sep 17 00:00:00 2001
From: podlesny <podlesny@zedat.fu-berlin.de>
Date: Sun, 28 Mar 2021 23:57:45 +0200
Subject: [PATCH] read params from output file

---
 data/tools/elias.py | 12 ++++++++----
 data/tools/main.py  | 23 +++++++----------------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/data/tools/elias.py b/data/tools/elias.py
index ff160cf2..d73b085f 100644
--- a/data/tools/elias.py
+++ b/data/tools/elias.py
@@ -19,6 +19,7 @@ from support.max_distance import max_distance
 
 from support.iterations import iterations
 from support.friction_stats import friction_stats
+from support.slip_rates import slip_rates
 
 def build_patch(coords, percentage):
     x_coords = coords[:, 0]
@@ -58,16 +59,19 @@ out_path = config.get('directories', 'output')
 h5path = os.path.join(sim_path)
 h5file = h5py.File(os.path.join(h5path, 'output.h5'), 'r')
 
+interval = [994, 996] 
+
 print(list(h5file.keys()))
 print(list(h5file['frictionalBoundary'].keys()))
 
-iterations(h5file, FINAL_TIME)
+iterations(h5file, FINAL_TIME, interval)
 
 coords = np.array(h5file['frictionalBoundary/coordinates'])
-patch = build_patch(coords, 0.05)
+patch = build_patch(coords, 1.0)
+
+friction_stats(h5file, 0, FINAL_TIME, patch, interval, TANGENTIAL_COORDS)
+slip_rates(h5file, 0, FINAL_TIME, patch, interval, TANGENTIAL_COORDS)
 
-friction_stats(h5file, 0, FINAL_TIME, [], [0, 50], TANGENTIAL_COORDS)
-    
 plt.show()
 
 h5file.close()
\ No newline at end of file
diff --git a/data/tools/main.py b/data/tools/main.py
index 1ba1c049..d18a1fa7 100644
--- a/data/tools/main.py
+++ b/data/tools/main.py
@@ -18,6 +18,7 @@ from support.slip_endings import slip_endings
 from support.max_distance import max_distance
 
 from support.io import read_h5file
+from support.io import read_params
 
 from support.iterations import iterations
 from support.friction_stats import friction_stats
@@ -34,27 +35,17 @@ def build_patch(coords, percentage):
 
     return [i for i in range(len(x_coords)) if x_coords[i]>=xmin and x_coords[i]<=xmax]
 
-
-NBODIES = 2
-FINAL_TIME = 15  # s
-FINAL_VELOCITY = 2e-4  # m/s
-THRESHOLD_VELOCITY = 0.5*FINAL_VELOCITY  # 1000e-6 + FINAL_VELOCITY
+# read problem parameters
+params = read_params('foam.cfg')
 
 TANGENTIAL_COORDS = 1
-
-# friction params
-params = {
-    'L'  : 1e-5,
-    'V0' : 1e-6,
-    'mu0': 0.6,
-    'a'  : 0.010,
-    'b'  : 0.015
-}
+FINAL_TIME = params['finalTime']
+NBODIES = params['bodyCount']
 
 h5file = read_h5file()
 print(list(h5file.keys()))
 
-interval = [10, 13] #[0.75*FINAL_TIME, FINAL_TIME]
+interval = [23, 24] #[0.75*FINAL_TIME, FINAL_TIME]
 
 iterations(h5file, FINAL_TIME, interval)
 
@@ -68,7 +59,7 @@ for body_ID in range(NBODIES):
     patch = build_patch(coords, 1.0)
 
     friction_stats(h5file, body_ID, FINAL_TIME, patch, interval)
-    slip_rates(h5file, body_ID, FINAL_TIME, patch, interval, 0)
+    slip_rates(h5file, body_ID, FINAL_TIME, patch, interval, TANGENTIAL_COORDS)
 
 plt.show()
 
-- 
GitLab