From 74dce30ff3192252b234ac9a01e89627b9df0587 Mon Sep 17 00:00:00 2001
From: podlesny <podlesny@zedat.fu-berlin.de>
Date: Fri, 19 Mar 2021 15:34:20 +0100
Subject: [PATCH] towards final foam output

---
 data/tools/config.ini                |  2 +-
 data/tools/main.py                   | 10 ++++---
 data/tools/support/friction_stats.py | 40 +++++++++++++++-------------
 data/tools/support/iterations.py     | 13 ++++-----
 4 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/data/tools/config.ini b/data/tools/config.ini
index 4eb55147..79c1ec79 100644
--- a/data/tools/config.ini
+++ b/data/tools/config.ini
@@ -4,6 +4,6 @@
  #/home/joscha/Downloads/
 
 [directories]
-simulation = /home/joscha/software/dune/build-release/dune-tectonic/src/foam/output/tresca-0.6/
+simulation = /home/joscha/software/dune/build-release/dune-tectonic/src/foam/output/pipping-2013-euler/
 experiment = ~/group/publications/2016-RosenauCorbiDominguezRudolfRitterPipping
 output     = generated
diff --git a/data/tools/main.py b/data/tools/main.py
index 0292562d..a3f8c770 100644
--- a/data/tools/main.py
+++ b/data/tools/main.py
@@ -35,7 +35,7 @@ def build_patch(coords, percentage):
 
 
 NBODIES = 2
-FINAL_TIME = 150  # s
+FINAL_TIME = 15  # s
 FINAL_VELOCITY = 2e-4  # m/s
 THRESHOLD_VELOCITY = 0.5*FINAL_VELOCITY  # 1000e-6 + FINAL_VELOCITY
 
@@ -53,7 +53,9 @@ params = {
 h5file = read_h5file()
 print(list(h5file.keys()))
 
-iterations(h5file, FINAL_TIME)
+interval = [0.75*FINAL_TIME, FINAL_TIME]
+
+iterations(h5file, FINAL_TIME, interval)
 
 for body_ID in range(NBODIES):
     body = 'body' + str(body_ID)
@@ -62,9 +64,9 @@ for body_ID in range(NBODIES):
         continue
 
     coords = np.array(h5file[body + '/coordinates'])
-    patch = build_patch(coords, 0.05)
+    patch = build_patch(coords, 1.0)
 
-    friction_stats(h5file, body_ID, FINAL_TIME, [], [0, FINAL_TIME])
+    friction_stats(h5file, body_ID, FINAL_TIME, patch, interval)
     
 plt.show()
 
diff --git a/data/tools/support/friction_stats.py b/data/tools/support/friction_stats.py
index 1fd7ae2c..9651d299 100644
--- a/data/tools/support/friction_stats.py
+++ b/data/tools/support/friction_stats.py
@@ -27,12 +27,13 @@ def friction_stats(h5file, body_ID, FINAL_TIME, patch=[], interval=[], TANGENTIA
     min_v = np.min(v_tx, axis=1)
     max_v = np.max(v_tx, axis=1)
     # plot
-    ax_slip = fig.add_subplot(3, 1, 1)
+    ax_slip = fig.add_subplot(2, 1, 1)
     #ax_slip.plot(time, min_v, color='gray', linestyle='--')
     ax_slip.plot(time, avg_v, color='black', linestyle='-')
     #ax_slip.plot(time, max_v, color='gray', linestyle='--')
-    ax_slip.set_ylabel('slip rate')
-    #ax_slip.set_yscale('log')
+    ax_slip.set_ylabel('slip rate V')
+    ax_slip.set_yscale('log')
+    ax_slip.set_ylim([1e-6,1e-2])
     #-------------------------
 
     print(np.min(min_v))
@@ -48,27 +49,28 @@ def friction_stats(h5file, body_ID, FINAL_TIME, patch=[], interval=[], TANGENTIA
     min_states = np.min(states_tx, axis=1)
     max_states = np.max(states_tx, axis=1)
     # plot
-    ax_state = fig.add_subplot(3, 1, 2)
-    ax_state.plot(time, min_states, color='gray', linestyle='--')
+    ax_state = fig.add_subplot(2, 1, 2)
+    #ax_state.plot(time, min_states, color='gray', linestyle='--')
     ax_state.plot(time, avg_states, color='black', linestyle='-')
-    ax_state.plot(time, max_states, color='gray', linestyle='--')
+    #ax_state.plot(time, max_states, color='gray', linestyle='--')
     ax_state.set_ylabel('state')
+    ax_state.set_xlabel('time in s')
     #-------------------------
 
     # friction coefficient
-    friction_coeff = np.array(h5file[body + '/coefficient'])
-    friction_coeff_t = friction_coeff[t,:]
-    friction_coeff_tx = friction_coeff_t[:,patch]
-    # statistics
-    avg_friction_coeff = np.average(friction_coeff_tx, axis=1)
-    min_friction_coeff = np.min(friction_coeff_tx, axis=1)
-    max_friction_coeff = np.max(friction_coeff_tx, axis=1)
-    # plot
-    ax_friction = fig.add_subplot(3, 1, 3)
-    ax_friction.plot(time, min_friction_coeff, color='gray', linestyle='--')
-    ax_friction.plot(time, avg_friction_coeff, color='black', linestyle='-')
-    ax_friction.plot(time, max_friction_coeff, color='gray', linestyle='--')
-    ax_friction.set_ylabel('friction coefficient')
+    # friction_coeff = np.array(h5file[body + '/coefficient'])
+    # friction_coeff_t = friction_coeff[t,:]
+    # friction_coeff_tx = friction_coeff_t[:,patch]
+    # # statistics
+    # avg_friction_coeff = np.average(friction_coeff_tx, axis=1)
+    # min_friction_coeff = np.min(friction_coeff_tx, axis=1)
+    # max_friction_coeff = np.max(friction_coeff_tx, axis=1)
+    # # plot
+    # ax_friction = fig.add_subplot(3, 1, 3)
+    # ax_friction.plot(time, min_friction_coeff, color='gray', linestyle='--')
+    # ax_friction.plot(time, avg_friction_coeff, color='black', linestyle='-')
+    # ax_friction.plot(time, max_friction_coeff, color='gray', linestyle='--')
+    # ax_friction.set_ylabel('friction coefficient')
     #-------------------------
 
     fig.canvas.draw()
\ No newline at end of file
diff --git a/data/tools/support/iterations.py b/data/tools/support/iterations.py
index b5b0b311..08279780 100644
--- a/data/tools/support/iterations.py
+++ b/data/tools/support/iterations.py
@@ -27,19 +27,20 @@ def iterations(h5file, FINAL_TIME, interval = []):
      # plot
     fig = plt.figure()
 
-    ax_fpi = fig.add_subplot(3, 1, 1)
+    ax_fpi = fig.add_subplot(2, 1, 1)
     ax_fpi.plot(time, fpi_final[t], color='black', linestyle='-')
     ax_fpi.set_ylabel('fpi')
     #-------------------------
 
-    ax_mg = fig.add_subplot(3, 1, 2)
+    ax_mg = fig.add_subplot(2, 1, 2)
     ax_mg.plot(time, multigrid_final[t], color='black', linestyle='-')
-    ax_mg.set_ylabel('multigrid')
+    ax_mg.set_ylabel('multigrid iter.')
+    ax_mg.set_xlabel('time in s')
     #-------------------------
 
-    ax_tau = fig.add_subplot(3, 1, 3)
-    ax_tau.plot(time, tau[t], color='black', linestyle='-')
-    ax_tau.set_ylabel('tau')
+    #ax_tau = fig.add_subplot(3, 1, 3)
+    #ax_tau.plot(time, tau[t], color='black', linestyle='-')
+    #ax_tau.set_ylabel('tau')
     #-------------------------
 
     fig.canvas.draw()
\ No newline at end of file
-- 
GitLab