polishing
This commit is contained in:
parent
2f16c1cacf
commit
771663c944
|
@ -8,9 +8,9 @@ def Cauchy(P,F):
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : numpy.array of shape (:,3,3) or (3,3)
|
F : numpy.ndarray of shape (:,3,3) or (3,3)
|
||||||
Deformation gradient.
|
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.
|
1. Piola-Kirchhoff stress.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -27,7 +27,7 @@ def deviatoric_part(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the deviatoric part is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -44,7 +44,7 @@ def eigenvalues(T_sym):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric tensor of which the eigenvalues are computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -59,7 +59,7 @@ def eigenvectors(T_sym,RHS=False):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric tensor of which the eigenvectors are computed.
|
||||||
RHS: bool, optional
|
RHS: bool, optional
|
||||||
Enforce right-handed coordinate system. Default is False.
|
Enforce right-handed coordinate system. Default is False.
|
||||||
|
@ -81,7 +81,7 @@ def left_stretch(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the left stretch is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -94,7 +94,7 @@ def maximum_shear(T_sym):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric tensor of which the maximum shear is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -109,7 +109,7 @@ def Mises_strain(epsilon):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric strain tensor of which the von Mises equivalent is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -122,7 +122,7 @@ def Mises_stress(sigma):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric stress tensor of which the von Mises equivalent is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -135,9 +135,9 @@ def PK2(P,F):
|
||||||
|
|
||||||
Parameters
|
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.
|
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.
|
Deformation gradient.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -154,7 +154,7 @@ def right_stretch(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the right stretch is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -167,7 +167,7 @@ def rotational_part(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the rotational part is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -180,7 +180,7 @@ def spherical_part(T,tensor=False):
|
||||||
|
|
||||||
Parameters
|
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 of which the hydrostatic part is computed.
|
||||||
tensor : bool, optional
|
tensor : bool, optional
|
||||||
Map spherical part onto identity tensor. Default is false
|
Map spherical part onto identity tensor. Default is false
|
||||||
|
@ -206,7 +206,7 @@ def strain_tensor(F,t,m):
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
F : numpy.array of shape (:,3,3) or (3,3)
|
F : numpy.ndarray of shape (:,3,3) or (3,3)
|
||||||
Deformation gradient.
|
Deformation gradient.
|
||||||
t : {‘V’, ‘U’}
|
t : {‘V’, ‘U’}
|
||||||
Type of the polar decomposition, ‘V’ for left stretch tensor and ‘U’ for right stretch tensor.
|
Type of the polar decomposition, ‘V’ for left stretch tensor and ‘U’ for right stretch tensor.
|
||||||
|
@ -241,7 +241,7 @@ def symmetric(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the symmetrized values are computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -254,7 +254,7 @@ def transpose(T):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the transpose is computed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -268,7 +268,7 @@ def __polar_decomposition(T,requested):
|
||||||
|
|
||||||
Parameters
|
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.
|
Tensor of which the singular values are computed.
|
||||||
requested : iterable of str
|
requested : iterable of str
|
||||||
Requested outputs: ‘R’ for the rotation tensor,
|
Requested outputs: ‘R’ for the rotation tensor,
|
||||||
|
@ -296,7 +296,7 @@ def __Mises(T_sym,s):
|
||||||
|
|
||||||
Parameters
|
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.
|
Symmetric tensor of which the von Mises equivalent is computed.
|
||||||
s : float
|
s : float
|
||||||
Scaling factor (2/3 for strain, 3/2 for stress).
|
Scaling factor (2/3 for strain, 3/2 for stress).
|
||||||
|
|
|
@ -5,22 +5,22 @@ import numpy as np
|
||||||
|
|
||||||
from . import version
|
from . import version
|
||||||
|
|
||||||
class Table():
|
class Table:
|
||||||
"""Store spreadsheet-like data."""
|
"""Store spreadsheet-like data."""
|
||||||
|
|
||||||
def __init__(self,data,shapes,comments=None):
|
def __init__(self,data,shapes,comments=None):
|
||||||
"""
|
"""
|
||||||
New spreadsheet.
|
New spreadsheet.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
data : numpy.ndarray or pandas.DataFrame
|
data : numpy.ndarray or pandas.DataFrame
|
||||||
Data. Column labels from a pandas.DataFrame will be replaced.
|
Data. Column labels from a pandas.DataFrame will be replaced.
|
||||||
shapes : dict with str:tuple pairs
|
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
|
comments : iterable of str, optional
|
||||||
Additional, human-readable information.
|
Additional, human-readable information.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.comments = [] if comments is None else [c for c in comments]
|
self.comments = [] if comments is None else [c for c in comments]
|
||||||
self.data = pd.DataFrame(data=data)
|
self.data = pd.DataFrame(data=data)
|
||||||
|
@ -35,8 +35,8 @@ class Table():
|
||||||
size = int(np.prod(shape))
|
size = int(np.prod(shape))
|
||||||
labels += ['{}{}'.format('' if size == 1 else '{}_'.format(i+1),label) for i in range(size)]
|
labels += ['{}{}'.format('' if size == 1 else '{}_'.format(i+1),label) for i in range(size)]
|
||||||
self.data.columns = labels
|
self.data.columns = labels
|
||||||
|
|
||||||
|
|
||||||
def __label_condensed(self):
|
def __label_condensed(self):
|
||||||
"""Label data condensed, e.g. 1_v 2_v 3_v ==> v v v."""
|
"""Label data condensed, e.g. 1_v 2_v 3_v ==> v v v."""
|
||||||
labels = []
|
labels = []
|
||||||
|
@ -51,7 +51,7 @@ class Table():
|
||||||
' '+str(shape) if np.prod(shape,dtype=int) > 1 else '',
|
' '+str(shape) if np.prod(shape,dtype=int) > 1 else '',
|
||||||
info))
|
info))
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_ASCII(fname):
|
def from_ASCII(fname):
|
||||||
"""
|
"""
|
||||||
|
@ -88,7 +88,7 @@ class Table():
|
||||||
comments.append(line.lstrip('#').strip())
|
comments.append(line.lstrip('#').strip())
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
labels = line.split()
|
labels = line.split()
|
||||||
|
|
||||||
shapes = {}
|
shapes = {}
|
||||||
for label in labels:
|
for label in labels:
|
||||||
tensor_column = re.search(r'[0-9,x]*?:[0-9]*?_',label)
|
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]),)
|
shapes[label.split('_',1)[1]] = (int(label.split('_',1)[0]),)
|
||||||
else:
|
else:
|
||||||
shapes[label] = (1,)
|
shapes[label] = (1,)
|
||||||
|
|
||||||
data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+')
|
data = pd.read_csv(f,names=list(range(len(labels))),sep=r'\s+')
|
||||||
|
|
||||||
return Table(data,shapes,comments)
|
return Table(data,shapes,comments)
|
||||||
|
@ -133,7 +133,7 @@ class Table():
|
||||||
except TypeError:
|
except TypeError:
|
||||||
f = fname
|
f = fname
|
||||||
f.seek(0)
|
f.seek(0)
|
||||||
|
|
||||||
content = f.readlines()
|
content = f.readlines()
|
||||||
|
|
||||||
comments = ['table.py:from_ang v {}'.format(version)]
|
comments = ['table.py:from_ang v {}'.format(version)]
|
||||||
|
@ -142,7 +142,7 @@ class Table():
|
||||||
comments.append(line.strip())
|
comments.append(line.strip())
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
data = np.loadtxt(content)
|
data = np.loadtxt(content)
|
||||||
for c in range(data.shape[1]-10):
|
for c in range(data.shape[1]-10):
|
||||||
shapes['n/a_{}'.format(c+1)] = (1,)
|
shapes['n/a_{}'.format(c+1)] = (1,)
|
||||||
|
@ -168,7 +168,7 @@ class Table():
|
||||||
if re.match(r'[0-9]*?_',label):
|
if re.match(r'[0-9]*?_',label):
|
||||||
idx,key = label.split('_',1)
|
idx,key = label.split('_',1)
|
||||||
data = self.data[key].to_numpy()[:,int(idx)-1].reshape((-1,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])
|
data = self.data[label].to_numpy().reshape((-1,)+self.shapes[label])
|
||||||
|
|
||||||
return data.astype(type(data.flatten()[0]))
|
return data.astype(type(data.flatten()[0]))
|
||||||
|
@ -194,7 +194,7 @@ class Table():
|
||||||
idx,key = label.split('_',1)
|
idx,key = label.split('_',1)
|
||||||
iloc = self.data.columns.get_loc(key).tolist().index(True) + int(idx) -1
|
iloc = self.data.columns.get_loc(key).tolist().index(True) + int(idx) -1
|
||||||
self.data.iloc[:,iloc] = data
|
self.data.iloc[:,iloc] = data
|
||||||
else:
|
else:
|
||||||
self.data[label] = data.reshape(self.data[label].shape)
|
self.data[label] = data.reshape(self.data[label].shape)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue