Commit ace2bea1 authored by mhuels's avatar mhuels
Browse files

Merge branch 'master' of gitlab.tubit.tu-berlin.de:m_huelsberg/analyzebd

 Conflicts:
	analyzebd/stress.py
parents 6a8089a0 cac6bb3d
......@@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.7 (analyzebd)" jdkType="Python SDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
......
......@@ -13,10 +13,10 @@ class Strain:
if(filename is None):
self.generate()
else:
self.read_from_file(filename)
self.readFromFile(filename)
def reset(self, filename):
self.read_from_file(filename)
self.readFromFile(filename)
def generate(self):
self.T = 1
......@@ -28,7 +28,7 @@ class Strain:
self.strainUnit = "y0"
self.strainConversion = self.A
def read_from_file(self, filename):
def readFromFile(self, filename):
self.dt = float(find_setting_in_file(filename.parent / "shearedSlitporeBD.out", "dt"))
self.T = float(find_setting_in_file(filename.parent / "shearedSlitporeBD.out", "oscillationPeriod"))
self.A = float(find_setting_in_file(filename.parent / "shearedSlitporeBD.out", "amplitude")) * self.T / (2 * math.pi)
......
import math
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
......@@ -43,7 +44,8 @@ class Stress:
i0 = int(tStart * self.timeConversion / self.dt_stress)
iEnd = None
if (tEnd is not None):
iEnd = int(tEnd * self.timeConversion / self.dt_stress)
# not optimal
iEnd = round(tEnd * self.timeConversion / self.dt_stress)
self.time = np.loadtxt(filename, skiprows=i0, max_rows=iEnd, usecols=0) * self.dt / self.timeConversion
self.shearRate = np.loadtxt(filename, skiprows=i0, max_rows=iEnd, usecols=1)
self.stress = np.loadtxt(filename, skiprows=i0, max_rows=iEnd, usecols=6)
......@@ -83,9 +85,9 @@ class Stress:
if(tStart is not None):
self.time -= tStart
# translated starting index due to shift
i0 = int(tStart * self.timeConversion / self.dt_stress)
i0 = round(tStart * self.timeConversion / self.dt_stress)
if(tEnd is not None):
iEnd = int(tEnd * self.timeConversion / self.dt_stress)
iEnd = round(tEnd * self.timeConversion / self.dt_stress)
self.time = self.time[i0:iEnd]
self.shearRate = self.shearRate[i0:iEnd]
self.stress = self.stress[i0:iEnd]
......@@ -111,6 +113,9 @@ class Stress:
self.stress = newStress
return self
def getTotalAverage(self):
return self.stress.mean()
def plotOverTime(self, ax=None, **kwargs):
if(ax is None):
ax = plt.subplot()
......@@ -125,13 +130,28 @@ class Stress:
ax.set_title("$T=$" f"{self.T}" "$\\tau_B, \\dot{\\gamma}_0=$" f"{self.A}" "$\\tau_B^{-1}$")
return ax
def plotVLB(self, ax=None, normalize=False, withColor=True, withColorBar=False, colormap="viridis", **kwargs):
def plotLB(self, ax=None, kind="viscous", normalize=False, withColor=True, withColorBar=False, colormap="viridis", **kwargs):
if(ax is None):
ax = plt.subplot()
if(kind == "viscous"):
x = self.shearRate
ax.set_xlabel("$\\dot{\\gamma}(t)/\\tau_B^{-1}$")
ax.set_title("Viscous Lissajou-Bowditch figure")
elif(kind == "elastic"):
x = np.array([self.A * self.T / self.timeConversion / (2 * math.pi) * math.sin(2*math.pi * t / self.T * self.timeConversion) for t in self.time])
ax.set_xlabel("$\\gamma(t)$")
ax.set_title("Elastic Lissajou-Bowditch figure")
else:
raise AttributeError(f"kind='{kind}' not supported. Choose either 'viscous' or 'elastic'.")
y = self.stress
ax.set_ylabel("$\\sigma_{xz}(t)/\\tilde{\\epsilon}d^{-3}$")
if(normalize):
x = self.shearRate / np.absolute(self.shearRate).max()
y = self.stress / np.absolute(self.stress).max()
ax.set_xlabel("$\\dot{\\gamma}(t)/\\dot{\\gamma}_0$")
x /= np.absolute(x).max()
y /= np.absolute(y).max()
if(kind == "viscous"):
ax.set_xlabel("$\\dot{\\gamma}(t)/\\dot{\\gamma}_0$")
else:
ax.set_xlabel("$\\gamma(t)/\\gamma_0$")
ax.set_ylabel("$\\sigma_{xz}(t)/\\sigma_{xz}^{max}$")
else:
x = self.shearRate
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment