Skip to content

Commit

Permalink
Merge pull request #37 from adtzlr/simplify
Browse files Browse the repository at this point in the history
Simplify the code
  • Loading branch information
adtzlr authored Mar 15, 2023
2 parents 9a168e5 + c8c6030 commit 40357ba
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 385 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format

## [Unreleased]

## [1.0.3] - 2023-03-15

### Changed
- Simplify the source code: Remove unused lines of code, To-Do's from function or class docstrings, unify file docstrings. Trim the header printed by `Model`.
- Build HTML and PDF logfiles only if `Settings.logpdf=True` (Pandoc and LaTeX must be installed). Otherwise, only the Markdown logfile `analysis.md` for `Model(logfile=True)` is created (no Pandoc install required).

## [1.0.2] - 2023-03-13

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/trusspy/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.2"
__version__ = "1.0.3"
29 changes: 5 additions & 24 deletions src/trusspy/core/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,48 @@ class Analysis:
U : None
placeholder for 2d-array with total displacement vector at the end of the inc.
`U.shape = (nnodes, ndim)`. To get Ux,Uy,Uz of node i type: `U[i]`
U0 : None
placeholder for 2d-array with total displacement vector at the beginning of the inc.
`U0.shape = (nnodes, ndim)`. To get U0x,U0y,U0z of node i type: `U0[i]`
placeholder for 2d-array with total displacement vector at the beginning of the
inc. `U0.shape = (nnodes, ndim)`. To get U0x,U0y,U0z of node i type: `U0[i]`
r : None
placeholder for 2d-array with internal force vector
`r.shape = (nnodes, ndim)`. To get rx,ry,rz of node i type: `r[i]`
g : None
placeholder for 2d-array with equilibrium vector
`g.shape = (nnodes, ndim)`. To get gx,gy,gz of node i type: `g[i]`
K : None
placeholder for 4d-array with stiffness matrix
`K.shape = (nnodes,nnodes,ndim,ndim)`. To get K with shape (ndim,ndim)
between force of node i w.r.t. displacement of node j type K[i,j].
stretch : None
placeholder for 2d-array with stretch vector
`stretch.shape = (nelems, 1)`. To get stretch of element i
type: `stretch[i]`
element_force : None
placeholder for 2d-array with element force vector
`element_force.shape = (nelems, 1)`. To get element_force of element i
type: `element_force[i]`
element_stress : None
placeholder for 2d-array with element stress vector
`element_stress.shape = (nelems, 1)`. To get element_stress of element i
type: `element_stress[i]`
element_stress0 : None
placeholder for 2d-array with element stress vector at the beginning of the increment
`element_stress0.shape = (nelems, 1)`. To get element_stress0 of element i
type: `element_stress0[i]`
placeholder for 2d-array with element stress vector at the beginning of the
increment ``element_stress0.shape = (nelems, 1)``. To get element_stress0 of
element ``i`` type: ``element_stress0[i]``.
DOF0 : None
placeholder for indices of inactive (locked) degree of freedoms
DOF1 : None
placeholder for indices of active (free) degree of freedoms
Ured : None
placeholder for reduced dispaclement vector
(only active components of U)
Vred : None
placeholder for reduced dispaclement vector
(only active components of V)
state_v : None
placeholder for state variable vector
Todo
----
* simplify reduced set with DOF1 read/write options
"""

def __init__(self):
Expand Down Expand Up @@ -122,9 +106,6 @@ def build(self, nnodes, nelems, ndim, DOF0, DOF1, nstatev=0):
ValueError : Result is not empty and can't be built.
Dimensions already set.
Todo
----
* simplify reduced slice read/write operations
"""
if self.U is None:
self.step = 1
Expand Down
3 changes: 0 additions & 3 deletions src/trusspy/core/boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ class BoundaryU:
Array of boundary components: `array([U1, U2, U3])`.
Set 1 for active (free) DOF and 0 for inactive (locked) DOF.
Todo
----
- rename to DOFState or something similar
"""

def __init__(self, node, values):
Expand Down
52 changes: 21 additions & 31 deletions src/trusspy/core/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@
class Element:
"""Element class.
Parameter
---------
label : int
Element ID number
conn : array_like
List of Element connectivity : `[Node 1, Node 2]`
elem_type : int, optional
Element Type. (default is 1 for truss)
mat_type : int, optional
Material Type. (default is 1 for linear-elastic)
material_properties : array_like, optional
List with material parameters,
e.g. [Young's modulus, Thermal expansion coefficient] (default is [])
geometric_properties : array_like, optional
List with geometric parameters,
e.g. [Section area] (default is [])
Attributes
----------
label : int
Expand All @@ -46,11 +28,6 @@ class Element:
List with geometric parameters,
e.g. [Section area] (default is [])
Todo
----
+ DONE rewrite material parameter storage
+ DONE material properties: type, mechanical and thermal parameter
+ DONE geometric porperties: section area
"""

def __init__(
Expand All @@ -64,6 +41,27 @@ def __init__(
mprop=None,
gprop=None,
):
"""Initialize an instance of the Element class.
Parameters
----------
label : int
Element ID number
conn : array_like
List of Element connectivity ``[Node 1, Node 2]``.
elem_type : int, optional
Element Type (default is 1 for "truss").
mat_type : int, optional
Material Type (default is 1 for "linear-elastic").
material_properties : array_like, optional
List with material parameters,
e.g. ``[Young's modulus, Thermal expansion coefficient]`` (default is
[np.nan]).
geometric_properties : array_like, optional
List with geometric parameters,
e.g. ``[Section area]`` (default is [np.nan]).
"""

self.label = label
self.conn = np.array(conn)
Expand All @@ -89,11 +87,3 @@ def __init__(
self.geometric_properties = gprop
else:
self.geometric_properties = geometric_properties

# def get_NE(self):
# """get end node of element"""
# return self.conn[1]

# def get_NA(self):
# """get begin node of element"""
# return self.conn[0]
25 changes: 13 additions & 12 deletions src/trusspy/core/external_force.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@
class ExternalForce:
"""External Force class.
Parameter
---------
node : int
Node ID number
force : array_like
List of Force components: `[F1, F2, F3]`
Attributes
----------
node : int
Node ID number
The node ID number,
force : ndarray
Array containing Force components `array([F1, F2, F3])`
Array containing force components ``array([F1, F2, F3])``.
TODO's
------
- add steps/stages by extending `force`
"""

def __init__(self, node, force):
"""External Force class.
Parameters
----------
node : int
The node ID number.
force : array_like
List of Force components ``[F1, F2, F3]``.
"""

self.node = node
self.force = np.array(force, dtype=float)
24 changes: 12 additions & 12 deletions src/trusspy/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
class Node:
"""Node class.
Parameter
---------
label : int
Node ID number
coord : array_like
List of node coordinates: `[X, Y, Z]`
Attributes
----------
label : int
Node ID number
coord : ndarray
List of node coordinates: `[X, Y, Z]`
List of node coordinates: ``[X, Y, Z]``
Todo
----
- add undeformed/deformed coordinates (useful?)
- copy deformed coordinates to result class at the end of each increment
"""

def __init__(self, label, coord):
"""Node class.
Parameters
----------
label : int
Node ID number
coord : array_like
List of node coordinates: ``[X, Y, Z]``
"""

self.label = label
self.coord = np.array(coord)
124 changes: 0 additions & 124 deletions src/trusspy/core/result.py

This file was deleted.

1 change: 0 additions & 1 deletion src/trusspy/elements/element_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def truss(
dx0 = dX + dU0

# elemental normal vector in deformed configuration
n0 = dx / np.linalg.norm(dx0)
n = dx / np.linalg.norm(dx)

# elemental length in undeformed and deformed configuration
Expand Down
Loading

0 comments on commit 40357ba

Please sign in to comment.