Skip to content

Commit

Permalink
lint black
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed May 8, 2023
1 parent 1f9bb5f commit 7ebe729
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 73 deletions.
42 changes: 22 additions & 20 deletions docs/examples/e102/e102.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@
"M = tp.Model(logfile=False)\n",
"\n",
"with M.Nodes as MN:\n",
" MN.add_node( 1, coord=( 0, 0, 0))\n",
" MN.add_node( 2, coord=( 1, 0, 1))\n",
" MN.add_node( 3, coord=( 2, 0, 0))\n",
" MN.add_node(1, coord=(0, 0, 0))\n",
" MN.add_node(2, coord=(1, 0, 1))\n",
" MN.add_node(3, coord=(2, 0, 0))\n",
"\n",
"with M.Elements as ME:\n",
" ME.add_element( 1, conn=(1,2), gprop=[1] )\n",
" ME.add_element( 2 ,conn=(2,3), gprop=[1] )\n",
" ME.add_element(1, conn=(1, 2), gprop=[1])\n",
" ME.add_element(2, conn=(2, 3), gprop=[1])\n",
"\n",
" E = 1 # elastic modulus\n",
" E = 1 # elastic modulus\n",
" ME.assign_material(\"all\", [E])\n",
"\n",
"with M.Boundaries as MB:\n",
" MB.add_bound_U( 1, (0,0,0) )\n",
" MB.add_bound_U( 2, (0,0,1) )\n",
" MB.add_bound_U( 3, (0,0,0) )\n",
" MB.add_bound_U(1, (0, 0, 0))\n",
" MB.add_bound_U(2, (0, 0, 1))\n",
" MB.add_bound_U(3, (0, 0, 0))\n",
"\n",
"with M.ExtForces as MF:\n",
" MF.add_force( 2, ( 0, 0,-1) )\n",
" MF.add_force(2, (0, 0, -1))\n",
"\n",
"M.Settings.incs = 100\n",
"M.Settings.xlimit = (2, 0.5)\n",
Expand Down Expand Up @@ -140,7 +140,7 @@
"fig, ax = M.plot_model(\n",
" view=\"xz\",\n",
" contour=\"force\",\n",
" lim_scale=(-1,3,-2.5,1.5),\n",
" lim_scale=(-1, 3, -2.5, 1.5),\n",
")"
]
},
Expand All @@ -162,7 +162,7 @@
}
],
"source": [
"fig, ax = M.plot_history(nodes=[2,2], X=\"Displacement Z\", Y=\"LPF\")"
"fig, ax = M.plot_history(nodes=[2, 2], X=\"Displacement Z\", Y=\"LPF\")"
]
},
{
Expand All @@ -181,15 +181,15 @@
"outputs": [],
"source": [
"with M.Elements as ME:\n",
" E = 1.0 # elastic modulus\n",
" K = 0.1 # plastic modulus\n",
" E = 1.0 # elastic modulus\n",
" K = 0.1 # plastic modulus\n",
" Sy = 0.1 # initial yield stress\n",
"\n",
" ME.assign_mtype(\"all\", 2)\n",
" ME.assign_material(\"all\", [E, K, Sy])\n",
"\n",
"M.build()\n",
"M.run() "
"M.run()"
]
},
{
Expand Down Expand Up @@ -220,11 +220,13 @@
}
],
"source": [
"fig, ax = M.plot_history(nodes=[2,2], X=\"Displacement Z\", Y=\"LPF\", fig=fig, ax=ax)\n",
"ax.legend([\n",
" \"Node 2: linear elastic\",\n",
" \"Node 2: elastic-plastic (isotropic hardening)\",\n",
"])\n",
"fig, ax = M.plot_history(nodes=[2, 2], X=\"Displacement Z\", Y=\"LPF\", fig=fig, ax=ax)\n",
"ax.legend(\n",
" [\n",
" \"Node 2: linear elastic\",\n",
" \"Node 2: elastic-plastic (isotropic hardening)\",\n",
" ]\n",
")\n",
"fig"
]
}
Expand Down
41 changes: 16 additions & 25 deletions docs/examples/e103/e103.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@
"M1 = tp.Model(logfile=False)\n",
"\n",
"with M1.Nodes as MN:\n",
" MN.add_node( 1, coord=( 0, 0, 0))\n",
" MN.add_node( 2, coord=( 1, 0, 3))\n",
" MN.add_node( 3, coord=( 2, 0, 0))\n",
" MN.add_node(1, coord=(0, 0, 0))\n",
" MN.add_node(2, coord=(1, 0, 3))\n",
" MN.add_node(3, coord=(2, 0, 0))\n",
"\n",
"with M1.Elements as ME:\n",
" ME.add_element( 1, conn=(1,2), gprop=[1] )\n",
" ME.add_element( 2 ,conn=(2,3), gprop=[1] )\n",
" ME.add_element(1, conn=(1, 2), gprop=[1])\n",
" ME.add_element(2, conn=(2, 3), gprop=[1])\n",
"\n",
" E = 1 # elastic modulus\n",
" E = 1 # elastic modulus\n",
" ME.assign_material(\"all\", [E])\n",
"\n",
"with M1.Boundaries as MB:\n",
" MB.add_bound_U( 1, (0,0,0) )\n",
" MB.add_bound_U( 2, (0,0,1) )\n",
" MB.add_bound_U( 3, (0,0,0) )\n",
" MB.add_bound_U(1, (0, 0, 0))\n",
" MB.add_bound_U(2, (0, 0, 1))\n",
" MB.add_bound_U(3, (0, 0, 0))\n",
"\n",
"with M1.ExtForces as MF:\n",
" MF.add_force( 2, ( 0, 0,-1) )\n",
" MF.add_force(2, (0, 0, -1))\n",
"\n",
"M1.Settings.incs = 150\n",
"M1.Settings.du = 0.01\n",
"M1.Settings.dlpf = 0.01\n",
"M1.Settings.xlimit = (1,10)\n",
"M1.Settings.xlimit = (1, 10)\n",
"M1.Settings.dlpf\n",
"M1.Settings.stepcontrol = True\n",
"M1.Settings.maxfac = 10"
Expand Down Expand Up @@ -139,12 +139,7 @@
}
],
"source": [
"fig, ax = M1.plot_model(\n",
" view=\"xz\",\n",
" contour=\"force\",\n",
" force_scale=2,\n",
" inc=20\n",
")"
"fig, ax = M1.plot_model(view=\"xz\", contour=\"force\", force_scale=2, inc=20)"
]
},
{
Expand All @@ -165,7 +160,7 @@
}
],
"source": [
"fig1, ax1 = M1.plot_history(nodes=[2,2], X=\"Displacement X\", Y=\"Displacement Z\")"
"fig1, ax1 = M1.plot_history(nodes=[2, 2], X=\"Displacement X\", Y=\"Displacement Z\")"
]
},
{
Expand All @@ -186,7 +181,7 @@
}
],
"source": [
"fig2, ax2 = M1.plot_history(nodes=[2,2], X=\"Displacement Z\", Y=\"LPF\")"
"fig2, ax2 = M1.plot_history(nodes=[2, 2], X=\"Displacement Z\", Y=\"LPF\")"
]
},
{
Expand Down Expand Up @@ -320,9 +315,7 @@
}
],
"source": [
"fig2, ax2 = M2.plot_history(\n",
" nodes=[2, 2], X=\"Displacement Z\", Y=\"LPF\", fig=fig2, ax=ax2\n",
")\n",
"fig2, ax2 = M2.plot_history(nodes=[2, 2], X=\"Displacement Z\", Y=\"LPF\", fig=fig2, ax=ax2)\n",
"ax2.legend([\"Node 2: basic model (nDOF=1)\", \"Node 2: imperfection (nDOF=2)\"])\n",
"fig2"
]
Expand Down Expand Up @@ -369,9 +362,7 @@
"metadata": {},
"outputs": [],
"source": [
"M2.plot_movie(\n",
" view=\"xz\", contour=\"force\", lim_scale=(-1, 4, -1, 4), force_scale=10\n",
")"
"M2.plot_movie(view=\"xz\", contour=\"force\", lim_scale=(-1, 4, -1, 4), force_scale=10)"
]
},
{
Expand Down
48 changes: 24 additions & 24 deletions docs/examples/eNTA-A/eNTA-A.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
"outputs": [],
"source": [
"with M.Nodes as MN:\n",
" MN.add_node( 1, coord=( 2.5 , 0 , 0 ))\n",
" MN.add_node( 2, coord=(-1.25, 1.25, 0 ))\n",
" MN.add_node( 3, coord=( 1 , 2 , 0 ))\n",
" MN.add_node( 4, coord=(-0.5 , 1.5 , 1.5))\n",
" MN.add_node( 5, coord=(-2.5 , 4.5 , 2.5))"
" MN.add_node(1, coord=(2.5, 0, 0))\n",
" MN.add_node(2, coord=(-1.25, 1.25, 0))\n",
" MN.add_node(3, coord=(1, 2, 0))\n",
" MN.add_node(4, coord=(-0.5, 1.5, 1.5))\n",
" MN.add_node(5, coord=(-2.5, 4.5, 2.5))"
]
},
{
Expand All @@ -75,8 +75,8 @@
"metadata": {},
"outputs": [],
"source": [
"element_type = 1 # truss\n",
"material_type = 1 # linear-elastic\n",
"element_type = 1 # truss\n",
"material_type = 1 # linear-elastic\n",
"\n",
"youngs_modulus = 1.0"
]
Expand All @@ -89,12 +89,12 @@
"outputs": [],
"source": [
"with M.Elements as ME:\n",
" ME.add_element( 1, conn=(1,4), gprop=[0.75] )\n",
" ME.add_element( 2 ,conn=(2,4), gprop=[1 ] )\n",
" ME.add_element( 3, conn=(3,4), gprop=[0.5 ] )\n",
" ME.add_element( 4, conn=(3,5), gprop=[0.75] )\n",
" ME.add_element( 5, conn=(2,5), gprop=[1 ] )\n",
" ME.add_element( 6, conn=(4,5), gprop=[1 ] )\n",
" ME.add_element(1, conn=(1, 4), gprop=[0.75])\n",
" ME.add_element(2, conn=(2, 4), gprop=[1])\n",
" ME.add_element(3, conn=(3, 4), gprop=[0.5])\n",
" ME.add_element(4, conn=(3, 5), gprop=[0.75])\n",
" ME.add_element(5, conn=(2, 5), gprop=[1])\n",
" ME.add_element(6, conn=(4, 5), gprop=[1])\n",
"\n",
" ME.assign_etype(\"all\", element_type)\n",
" ME.assign_mtype(\"all\", material_type)\n",
Expand All @@ -117,14 +117,14 @@
"outputs": [],
"source": [
"with M.Boundaries as MB:\n",
" MB.add_bound_U( 1, (0,0,0) )\n",
" MB.add_bound_U( 2, (0,0,0) )\n",
" MB.add_bound_U( 3, (0,0,0) )\n",
" MB.add_bound_U( 5, (1,0,1) )\n",
" MB.add_bound_U(1, (0, 0, 0))\n",
" MB.add_bound_U(2, (0, 0, 0))\n",
" MB.add_bound_U(3, (0, 0, 0))\n",
" MB.add_bound_U(5, (1, 0, 1))\n",
"\n",
"with M.ExtForces as MF:\n",
" MF.add_force( 4, ( 1, 1,-1) )\n",
" MF.add_force( 5, (-2, 0,-2) )"
" MF.add_force(4, (1, 1, -1))\n",
" MF.add_force(5, (-2, 0, -2))"
]
},
{
Expand Down Expand Up @@ -245,13 +245,13 @@
"# LOGFILE \"analysis.log\"\n",
"\n",
"total cpu time \"build\": 0.001 seconds\n",
"total wall time \"build\": 0.001 seconds\n",
"total wall time \"build\": 0.000 seconds\n",
"\n",
"total cpu time \"run\": 6.739 seconds\n",
"total wall time \"run\": 6.737 seconds\n",
"total cpu time \"run\": 1.546 seconds\n",
"total wall time \"run\": 1.547 seconds\n",
"```\n",
"\n",
"For example at increment 40 a converged solution was obtained within 4 iterations plus one iteration to get the new control component. The determination of the control component is based on a linear solution (only 1 Newton-Rhapson iteration) for the current allowed incremental LPF. The sign of this allowed incremental LPF is estimated with the sign of the determinant of the stiffness matrix `det(KT)`. The vector norm of the equilibrium equations and the incremental system vector both satisfy the specified tolerance `tol = 1e-8` at the end of the increment. The 5th component of the incremental system vector (+DOF 5) is used as control component for the path tracing algorithm. No overshoot is detected - the control equation was fullfilled. The 2nd biggest displacement is -DOF 4 with a relative displacement of `-0.3168` compared to the allowed value. As the maximum incremental stepwidth was already reached in increment 8 and that there were no convergence problemes during this increment the allowed incremental system vector is whether increased nor decreased by the automatic stepcontrol. The final LPF at the end of increment 40 is `LPF(inc 40) = -0.003547`.\n",
"For example at increment 40 a converged solution was obtained within 4 iterations plus one iteration to get the new control component. The determination of the control component is based on a linear solution (only 1 Newton-Rhapson iteration) for the current allowed incremental LPF. The sign of this allowed incremental LPF is estimated with the sign of the determinant of the stiffness matrix `det(KT)`. The vector norm of the equilibrium equations and the incremental system vector both satisfy the specified tolerance `tol = 1e-8` at the end of the increment. The 5th component of the incremental system vector (+DOF 5) is used as control component for the path tracing algorithm. No overshoot is detected - the control equation was fullfilled. The 2nd biggest displacement is +DOF 4 with a relative displacement of `-0.2549` compared to the allowed value. The final LPF at the end of increment 40 is given in the last line of the output.\n",
"\n",
"```\n",
"### Increment 40\n",
Expand Down Expand Up @@ -513,7 +513,7 @@
}
],
"source": [
"M.Results.R[40].g.reshape(M.nnodes,M.ndim)"
"M.Results.R[40].g.reshape(M.nnodes, M.ndim)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/trusspy/handlers/handler_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def __init__(self):

def add_increment(self, analysis=None, extforces=None, lpf=None):
"add single Result to ResultManager"

if analysis is None:
result = Analysis()
else:
result = copy.deepcopy(analysis)

if extforces is not None:
result.ExtForces = copy.deepcopy(extforces)
result.ExtForces.forces_const = np.zeros_like(result.U)
result.ExtForces.forces_const = np.zeros_like(result.U)

result.lpf = lpf

Expand Down
4 changes: 3 additions & 1 deletion src/trusspy/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def build(self):

# init results, add empty increment
self.Results.add_increment(
analysis=self.Analysis, extforces=self.ExtForces, lpf=0,
analysis=self.Analysis,
extforces=self.ExtForces,
lpf=0,
)

self.clock1_build = time.perf_counter()
Expand Down

0 comments on commit 7ebe729

Please sign in to comment.