tUpdate hanzen-zoet experiments and results visualization - sphere - GPU-based … | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit ae848a4aea82c97555e701465d26bba60ba80f76 | |
parent 5f03b9fa9d946daf18bb119e7c181bcfe41a31d6 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 12 May 2020 10:24:43 +0200 | |
Update hanzen-zoet experiments and results visualization | |
Diffstat: | |
A python/hansen-zoet-plots.py | 51 +++++++++++++++++++++++++++++… | |
M python/hansen-zoet.py | 14 +++++++++----- | |
2 files changed, 60 insertions(+), 5 deletions(-) | |
--- | |
diff --git a/python/hansen-zoet-plots.py b/python/hansen-zoet-plots.py | |
t@@ -0,0 +1,51 @@ | |
+#!/usr/bin/env python | |
+ | |
+# Import sphere functionality | |
+import sphere | |
+import numpy | |
+import matplotlib.pyplot as plt | |
+from sklearn.linear_model import LinearRegression | |
+ | |
+# Number of particles | |
+np = 1e4 | |
+ | |
+# Common simulation id | |
+sim_id = "hz" | |
+ | |
+# Deviatoric stress [Pa] | |
+Nlist = numpy.array([51e3, 101e3, 202e3, 303e3, 404e3]) | |
+ | |
+### INITIALIZATION ### | |
+ | |
+# New class | |
+sim = sphere.sim(np = np, nd = 3, nw = 0, sid = sim_id + "-init") | |
+ | |
+N_avg = 50 | |
+tau_c = [] | |
+ | |
+for N in Nlist: | |
+ sim.id("{}-shear-N{}".format(sim_id, N)) | |
+ lastf = sim.status() | |
+ #sim.readlast() | |
+ #sim.sheardisp() | |
+ | |
+ # average shear stress over last files | |
+ tau_c_curr = 0.0 | |
+ | |
+ for i in range(N_avg): | |
+ sim.readstep(lastf - i) | |
+ tau_c_curr += sim.shearStress('effective') | |
+ tau_c.append(tau_c_curr/N_avg) | |
+ | |
+fig = plt.figure() | |
+tau_c = numpy.array(tau_c) | |
+tau_c /= 1e3 | |
+Nlist /= 1e3 | |
+plt.plot(Nlist, tau_c, '+') | |
+mc = LinearRegression().fit(Nlist.reshape((-1, 1)), tau_c) | |
+Nspace = numpy.linspace(0.0, Nlist[-1], endpoint=True) | |
+plt.plot(Nspace, mc.predict(Nspace.reshape(-1,1)), '-') | |
+plt.title("friction = {:.2}, cohesion = {:.2} kPa".format(mc.coef_[0], mc.inte… | |
+plt.xlabel("Effective normal stress [kPa]") | |
+plt.ylabel("Shear stress [kPa]") | |
+plt.savefig("hz-mohr-coulomb.pdf") | |
diff --git a/python/hansen-zoet.py b/python/hansen-zoet.py | |
t@@ -5,7 +5,7 @@ import sphere | |
### EXPERIMENT SETUP ### | |
initialization = False | |
-consolidation = False | |
+consolidation = True | |
shearing = True | |
rendering = False | |
plots = True | |
t@@ -16,8 +16,12 @@ np = 1e4 | |
# Common simulation id | |
sim_id = "hz" | |
+# Use specified compute device (-1 for autoselect) | |
+device = 1 | |
+ | |
# Deviatoric stress [Pa] | |
-Nlist = [51e3, 101e3, 202e3, 303e3, 404e3] | |
+#Nlist = [51e3, 101e3, 202e3, 303e3, 404e3] | |
+Nlist = [404e3] | |
### INITIALIZATION ### | |
t@@ -47,7 +51,7 @@ if (initialization == True): | |
# Run sphere | |
init.run(dry = True) | |
- init.run() | |
+ init.run(device=device) | |
if (plots == True): | |
# Make a graph of energies | |
t@@ -97,7 +101,7 @@ for N in Nlist: | |
# Run sphere | |
cons.run(dry = True) # show values, don't run | |
- cons.run() # run | |
+ cons.run(device=device) # run | |
if (plots == True): | |
# Make a graph of energies | |
t@@ -138,7 +142,7 @@ for N in Nlist: | |
# Run sphere | |
shear.run(dry = True) | |
- shear.run() | |
+ shear.run(device=device) | |
if (plots == True): | |
# Make a graph of energies |