polishing

This commit is contained in:
Martin Diehl 2020-03-13 00:30:49 +01:00
parent 2f16c1cacf
commit 771663c944
2 changed files with 33 additions and 33 deletions

View File

@ -8,9 +8,9 @@ def Cauchy(P,F):
Parameters
----------
F : numpy.array of shape (:,3,3) or (3,3)
F : numpy.ndarray of shape (:,3,3) or (3,3)
Deformation gradient.
P : numpy.array of shape (:,3,3) or (3,3)
P : numpy.ndarray of shape (:,3,3) or (3,3)
1. Piola-Kirchhoff stress.
"""
@ -27,7 +27,7 @@ def deviatoric_part(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the deviatoric part is computed.
"""
@ -44,7 +44,7 @@ def eigenvalues(T_sym):
Parameters
----------
T_sym : numpy.array of shape (:,3,3) or (3,3)
T_sym : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric tensor of which the eigenvalues are computed.
"""
@ -59,7 +59,7 @@ def eigenvectors(T_sym,RHS=False):
Parameters
----------
T_sym : numpy.array of shape (:,3,3) or (3,3)
T_sym : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric tensor of which the eigenvectors are computed.
RHS: bool, optional
Enforce right-handed coordinate system. Default is False.
@ -81,7 +81,7 @@ def left_stretch(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the left stretch is computed.
"""
@ -94,7 +94,7 @@ def maximum_shear(T_sym):
Parameters
----------
T_sym : numpy.array of shape (:,3,3) or (3,3)
T_sym : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric tensor of which the maximum shear is computed.
"""
@ -109,7 +109,7 @@ def Mises_strain(epsilon):
Parameters
----------
epsilon : numpy.array of shape (:,3,3) or (3,3)
epsilon : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric strain tensor of which the von Mises equivalent is computed.
"""
@ -122,7 +122,7 @@ def Mises_stress(sigma):
Parameters
----------
sigma : numpy.array of shape (:,3,3) or (3,3)
sigma : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric stress tensor of which the von Mises equivalent is computed.
"""
@ -135,9 +135,9 @@ def PK2(P,F):
Parameters
----------
P : numpy.array of shape (:,3,3) or (3,3)
P : numpy.ndarray of shape (:,3,3) or (3,3)
1. Piola-Kirchhoff stress.
F : numpy.array of shape (:,3,3) or (3,3)
F : numpy.ndarray of shape (:,3,3) or (3,3)
Deformation gradient.
"""
@ -154,7 +154,7 @@ def right_stretch(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the right stretch is computed.
"""
@ -167,7 +167,7 @@ def rotational_part(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the rotational part is computed.
"""
@ -180,7 +180,7 @@ def spherical_part(T,tensor=False):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the hydrostatic part is computed.
tensor : bool, optional
Map spherical part onto identity tensor. Default is false
@ -206,7 +206,7 @@ def strain_tensor(F,t,m):
Parameters
----------
F : numpy.array of shape (:,3,3) or (3,3)
F : numpy.ndarray of shape (:,3,3) or (3,3)
Deformation gradient.
t : {V, U}
Type of the polar decomposition, V for left stretch tensor and U for right stretch tensor.
@ -241,7 +241,7 @@ def symmetric(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the symmetrized values are computed.
"""
@ -254,7 +254,7 @@ def transpose(T):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the transpose is computed.
"""
@ -268,7 +268,7 @@ def __polar_decomposition(T,requested):
Parameters
----------
T : numpy.array of shape (:,3,3) or (3,3)
T : numpy.ndarray of shape (:,3,3) or (3,3)
Tensor of which the singular values are computed.
requested : iterable of str
Requested outputs: R for the rotation tensor,
@ -296,7 +296,7 @@ def __Mises(T_sym,s):
Parameters
----------
T_sym : numpy.array of shape (:,3,3) or (3,3)
T_sym : numpy.ndarray of shape (:,3,3) or (3,3)
Symmetric tensor of which the von Mises equivalent is computed.
s : float
Scaling factor (2/3 for strain, 3/2 for stress).

View File

@ -5,22 +5,22 @@ import numpy as np
from . import version
class Table():
class Table:
"""Store spreadsheet-like data."""
def __init__(self,data,shapes,comments=None):
"""
New spreadsheet.
Parameters
----------
data : numpy.ndarray or pandas.DataFrame
Data. Column labels from a pandas.DataFrame will be replaced.
shapes : dict with str:tuple pairs
Shapes of the columns. Example 'F':(3,3) for a deformation gradient.
Shapes of the columns. Example 'F':(3,3) for a deformation gradient.
comments : iterable of str, optional
Additional, human-readable information.
"""
self.comments = [] if comments is None else [c for c in comments]
self.data = pd.DataFrame(data=data)
@ -35,8 +35,8 @@ class Table():
size = int(np.prod(shape))
labels += ['{}{}'.format('' if size == 1 else '{}_'.format(i+1),label) for i in range(size)]
self.data.columns = labels
def __label_condensed(self):
"""Label data condensed, e.g. 1_v 2_v 3_v ==> v v v."""
labels = []
@ -51,7 +51,7 @@ class Table():
' '+str(shape) if np.prod(shape,dtype=int) > 1 else '',
info))
@staticmethod
def from_ASCII(fname):
"""
@ -88,7 +88,7 @@ class Table():
comments.append(line.lstrip('#').strip())
line = f.readline().strip()
labels = line.split()
shapes = {}
for label in labels:
tensor_column = re.search(r'[0-9,x]*?:[0-9]*?_',label)
@ -101,7 +101,7 @@ class Table():
shapes[label.split('_',1)[1]] = (int(label.split('_',1)[0]),)
else:
shapes[label] = (1,)
data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+')
return Table(data,shapes,comments)
@ -133,7 +133,7 @@ class Table():
except TypeError:
f = fname
f.seek(0)
content = f.readlines()
comments = ['table.py:from_ang v {}'.format(version)]
@ -142,7 +142,7 @@ class Table():
comments.append(line.strip())
else:
break
data = np.loadtxt(content)
for c in range(data.shape[1]-10):
shapes['n/a_{}'.format(c+1)] = (1,)
@ -168,7 +168,7 @@ class Table():
if re.match(r'[0-9]*?_',label):
idx,key = label.split('_',1)
data = self.data[key].to_numpy()[:,int(idx)-1].reshape((-1,1))
else:
else:
data = self.data[label].to_numpy().reshape((-1,)+self.shapes[label])
return data.astype(type(data.flatten()[0]))
@ -194,7 +194,7 @@ class Table():
idx,key = label.split('_',1)
iloc = self.data.columns.get_loc(key).tolist().index(True) + int(idx) -1
self.data.iloc[:,iloc] = data
else:
else:
self.data[label] = data.reshape(self.data[label].shape)