Comments (2)
Okay, here is a tutorial how to achieve this with the current code of TrussPy (please update TrussPy via pip first):
Create a Model
In a first step we have to create the Model and set the maximum allowed increments to 1 (0 is not possible in TrussPy). We call this function create_model
.
import trusspy as tp
def create_model():
'''Create a TrussPy-Model and return the Model instance.'''
M = tp.Model(log=0)
with M.Nodes as MN:
MN.add_node( 1, coord=( 0, 0, 0))
MN.add_node( 2, coord=( 1, 0, 1))
MN.add_node( 3, coord=( 2, 0, 0))
with M.Elements as ME:
ME.add_element( 1, conn=(1,2), gprop=[1] )
ME.add_element( 2 ,conn=(2,3), gprop=[1] )
ME.assign_material( 'all', [1])
with M.Boundaries as MB:
MB.add_bound_U( 1, (0,0,0) )
MB.add_bound_U( 2, (0,0,1) )
MB.add_bound_U( 3, (0,0,0) )
with M.ExtForces as MF:
MF.add_force( 2, ( 0, 0,-1) )
M.Settings.incs = 1
return M
Function for stiffness evaluation
In a second step we create a function which uses a list of elemental areas as its argument, runs the model and returns the stiffness matrix for the initial increment of zero deformation (may be adapted to your needs). Finally a reduced stiffness matrix for all active degree of freedoms (Kred
) is returned. This may also be changed to the whole system stiffness matrix (K
) or the one which is used by TrussPy (Kmod
). See the documentation for further informations about Kmod
.
def stiffness(list_of_areas):
'''Calculate the stiffness matrix as a function of elemental
cross-section areas (passed as list).'''
M = create_model()
M.Elements.assign_geometries('all', list_of_areas)
M.build()
M.run()
R0 = M.Results.R[0]
# return K (full system), Kred (only active DOF)
# or Kmod (see Documentation)
return R0.Kred
Now we have a function which evaluates the stiffness matrix based on a list of elemental areas.
Code snippet inside a script
list_of_areas = [2,3]
K = stiffness(list_of_areas)
Have fun!
from trusspy.
@Giannis1993 please have a look - hope that helps!
from trusspy.
Related Issues (20)
- Setup GitHub Actions
- No such file or directory: 'pandoc' HOT 6
- Docs are broken
- Docs: Use a mobile-friendly HTML theme
- MyBinder: install trusspy
- Docstrings of source `*.py`-files are not consistent
- The source contains a lot of unused files and to-do references
- The keyword `fps` is no longer supported. Use `duration`(in ms) instead HOT 1
- Simplify `Model.plot_model()`
- First Result `M.Results.R[0].U` contains the first solution `M.Results.R[1].U` instead of the initial state `M.Results.R[0].U0`
- Docs: Update figures of Examples
- Drop Support for PDF- and HTML-Logfiles
- Docs: Getting-Started: Merge static and interactive versions
- `Model.plot_history()`: Given increments are ignored
- `Model.plot_model(inc=0)` raises an Error before `Model.run()` is called
- `Model.plot_movie(incs="all")`: Number of increments are not created from the list of results
- Python 3.7 is EOL (end of life)
- [Question] Did you publish a paper for this library? Like in JOSS HOT 3
- [Python] Usage of __slots__ or @dataclass(slots=True) in python classes for reducing memory usage and performance improvement HOT 2
- [Question] Which units should be used? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trusspy.