-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42c1b6d
commit 75ce1c0
Showing
3 changed files
with
47 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 33 additions & 2 deletions
35
tests/integration/getting_started_models/example_model2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,71 @@ | ||
# The Model object is used to set up the entire structure model, and to run a | ||
# beam analysis | ||
from framat import Model | ||
|
||
# Create a new instance of the Model object | ||
model = Model() | ||
|
||
# ===== MATERIAL ===== | ||
# Create a material definition which can be referenced when creating beams. | ||
# Note that you can add as many materials as you want. Just provide a different | ||
# UID (unique identifier) for each new material. Below we define the Young's | ||
# modulus, the shear modulus and the density. | ||
mat = model.add_feature('material', uid='dummy') | ||
mat.set('E', 1) | ||
mat.set('G', 1) | ||
mat.set('rho', 1) | ||
|
||
# ===== CROSS SECTION ===== | ||
# Besides material data, we also need cross section geometry, or more | ||
# specifically, the cross section area, the second moments of area, and the | ||
# torsional constant. | ||
cs = model.add_feature('cross_section', uid='dummy') | ||
cs.set('A', 1) | ||
cs.set('Iy', 1) | ||
cs.set('Iz', 1) | ||
cs.set('J', 1) | ||
|
||
# ===== BEAM ===== | ||
# Next, let's add a beam! We define the geometry using "named nodes", that is, | ||
# we provide the coordinates of some "support nodes" which can be referred to | ||
# with their UIDs. | ||
beam = model.add_feature('beam') | ||
beam.add('node', [0.0, 0, 0], uid='a') | ||
beam.add('node', [1.5, 0, 0], uid='b') | ||
beam.add('node', [1.5, 3, 0], uid='c') | ||
beam.add('node', [0.0, 3, 0], uid='d') | ||
# Set the number of elements for the beam. | ||
beam.set('nelem', 40) | ||
# Set the material, cross section and cross section orientation | ||
beam.add('material', {'from': 'a', 'to': 'd', 'uid': 'dummy'}) | ||
beam.add('cross_section', {'from': 'a', 'to': 'd', 'uid': 'dummy'}) | ||
beam.add('orientation', {'from': 'a', 'to': 'd', 'up': [0, 0, 1]}) | ||
|
||
# Add some line loads [N/m] and point loads [N] | ||
beam.add('distr_load', {'from': 'a', 'to': 'b', 'load': [0, 0, -2, 0, 0, 0]}) | ||
beam.add('distr_load', {'from': 'c', 'to': 'd', 'load': [0, 0, -2, 0, 0, 0]}) | ||
beam.add('distr_load', {'from': 'b', 'to': 'c', 'load': [0, 0, 1, 0, 0, 0]}) | ||
beam.add('point_load', {'at': 'b', 'load': [+0.1, +0.2, +0.3, 0, 0, 0]}) | ||
beam.add('point_load', {'at': 'c', 'load': [-0.1, -0.2, -0.3, 0, 0, 0]}) | ||
|
||
# ===== BOUNDARY CONDITIONS ===== | ||
# We also must constrain our model. Below, we fix the nodes 'a' and 'd' | ||
bc = model.set_feature('bc') | ||
bc.add('fix', {'node': 'a', 'fix': ['all']}) | ||
bc.add('fix', {'node': 'd', 'fix': ['all']}) | ||
|
||
# ===== POST-PROCESSING ===== | ||
# By default the analysis is run without any GUI, but to get a visual | ||
# representation of the results we can create a plot | ||
pp = model.set_feature('post_proc') | ||
pp.set('plot_settings', {'show': True}) | ||
pp.add('plot', ['undeformed', 'deformed', 'node_uids', 'nodes', 'forces']) | ||
|
||
model.run() | ||
# Run the beam analysis | ||
results = model.run() | ||
|
||
# ===== RESULTS ===== | ||
# The result object contains all relevant results. For instance, we may fetch | ||
# the global load vector. | ||
load_vector = results.get('tensors').get('F') | ||
print(load_vector) | ||
... |