Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #37 from spacether/feature/adds_samples_testing
Browse files Browse the repository at this point in the history
Feature/adds samples testing
  • Loading branch information
spacether authored Jun 16, 2018
2 parents 158378c + ad28d83 commit 499a262
Show file tree
Hide file tree
Showing 40 changed files with 4,967 additions and 1,858 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ presentations/
pycalculix.egg-info/
__pycache__

# calculix docs
ccx_2.13.pdf
cgx_2.13.pdf
# tests
.pytest_cache
21 changes: 19 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ clean_examples:
rm -f ./examples/*.sta
rm -f ./examples/*.out

clean:
rm -f ./*.fbd
rm -f ./*.inp
rm -f ./*.geo
rm -f ./*.msh
rm -f ./*.frd
rm -f ./*.dat
rm -f ./*.png
rm -f ./*.cvg
rm -f ./*.sta
rm -f ./*.out


dist_examples:
make clean_examples
zip -r examples.zip examples
Expand All @@ -28,6 +41,7 @@ dist_docs:
rm -rf docs
rm -rf documentation
sphinx-apidoc -F -A "Justin Black" -o docs pycalculix
echo ' ' >> docs/conf.py
echo 'from pycalculix.version import __version__' >> docs/conf.py
echo 'version = __version__' >> docs/conf.py
echo 'release = version' >> docs/conf.py
Expand All @@ -48,10 +62,13 @@ dist_source:
rm -rf *.egg-info

develop:
python3 setup.py develop
pip3 install -e .

install:
python3 setup.py install
pip3 install .

uninstall:
pip3 uninstall pycalculix

test:
pytest tests/
64 changes: 46 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,24 @@ Setting element divisions on lines is supported
- Gravity
- Rotational speed forces
- Displacement constraints
- Loads are stored on geometry primitives (points lines, areas) and can be
applied before or after meshing.
- Loads are stored on geometry primitives (points lines, areas) and
can be applied before or after meshing.


## Files Produced
Meshing and solving are done in the background using cgx or gmsh for meshing, and Calculix ccx for solving.
Meshing and solving are done in the background using cgx or gmsh for
meshing, and Calculix ccx for solving.

Files Used:
- .fbd (Calculix cgx gemetry file)
- .inp (Calculix solver input file, or mesh definition)
- .geo (Gmsh geometry file)
- .msh (Gmsh native mesh file)
- .frd (Calculix ccx nodal results file, values are at nodes and were created by interpolating element integration point results back to the nodes)
- .dat (Calculix ccx element results file, includes integration point results)
- .frd (Calculix ccx nodal results file, values are at nodes and were
created by interpolating element integration point results back to
the nodes)
- .dat (Calculix ccx element results file, includes integration point
results)


## Uninstall
Expand Down Expand Up @@ -210,8 +214,8 @@ python -m venv venv
pip install -e .
pycalculix-add-feaprograms
```
- Now any changes that you make to your local version of pycalculix will be
live in your virtual environment
- Now any changes that you make to your local version of pycalculix
will be live in your virtual environment

## License
See LICENSE.txt (Apache 2.0)
Expand All @@ -224,15 +228,43 @@ Initial Release: December 2014

## Change Log

#### 0.9.5 (github only)
- Currently in branch 'feature/adds_samples_testing'
- Adds tests: sample tests at tests/test_samples.py
- Adds tests: meshing tests at tests/test_meshing.py
- Adds solving and meshing timeout exception to capture when they hang
- Fixes dxf import feature, syntax updates to use dfxgrabber >= 0.8.0,
Issue 32
- Adds requirement for dfxgrabber >= 0.8.0 to ensure that dxf import works
- Pegs Mac gmsh version to gmsh == 3.0.5 because version 3.0.6
throws segault errors when meshing
- Fixes a bug where solver input file does not write material before
time steps, Issue 32
- Fixed ccx installer on Windows: zip file is now found and
downloaded
- Throws an exception if ccx version is too old, v 2.7 and earlier is
too old
- Pegs Win gmsh install version to 3.0.5
- Updates the calculation for element Seqv, S1, S2, and S3 avg max
and min values. Now calculates Seqv and principal stresses at all
integration points, then calculates the avg max and min of those
values
- Win pegged ccx to version 2.12
- Mac brew brewsci/science/calculix-ccx is currently at ccx version 2.13
- Ubuntu apt-get calculix-ccx is currently is currently at version 2.11

#### 0.9.4 (github only)
- removed gmsh and calculix
- moved dist and documentation building and example cleanup into make file
- moved dist and documentation building and example cleanup into make
file
- changed the license to Apache 2.0
- added command line tool to install/uninstall gmsh and ccx for windows/mac os x/ubuntu
- added command line tool to install/uninstall gmsh and ccx for
windows/mac os x/ubuntu
- pycalculix-add-feaprograms
- pycalculix-remove-feaprograms
- added requests library requirement for pycalculix-add-feaprograms
- fixed bug where frd files could no longer be read
- fixed bug where frd files could no longer be read because Calculix
results keywords changed since initial 2014 release

#### 0.9.3
- ADDED: multiple parts with contacts
Expand Down Expand Up @@ -274,17 +306,13 @@ Initial Release: December 2014
- pycalculix.FeaModel.make_problem or pycalculix.Problem
- Make Results File:
- pycalculix.Problem.rfile or pycalculix.ResultsFile(problem)
- FIX: Plotting fix, closing triangles in the correct direction in matplotlib
- FIX: Plotting fix, closing triangles in the correct direction in
matplotlib
- DOC: All code separated into modules for clarity.
- DOC: Docstrings added to all classes + methods + functions
- PLOTTING: Closed areas are now filled in yellow when plotting geometry.
- PLOTTING: Closed areas are now filled in yellow when plotting
geometry.
- PLOTTING: Signed line names are shown and internal to the area.
- BACKEND: Implemented signed line and signed arc class.
- Pressures can now be applied on these signed lines.
- Many methods and variables made private to clean up name space.

## Developer Todo:
- confirm that set_ediv still works, remove the past merge if that broke it
- add images to the readme
- add new release on github release branch
- add new release on pypi
Binary file modified dist/documentation.zip
Binary file not shown.
Binary file modified dist/examples.zip
Binary file not shown.
Binary file removed dist/pycalculix-0.9.4.zip
Binary file not shown.
Binary file added dist/pycalculix-0.9.5.zip
Binary file not shown.
Binary file removed examples/Pycalculix_Overview_2014-12-22.pdf
Binary file not shown.
38 changes: 28 additions & 10 deletions examples/compr-rotor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#!/usr/bin/env python3
import math
import sys

import pycalculix as pyc
import matplotlib.pyplot as plt
import math

# We'll be modeling a rotating jet engine part
model_name = 'compr-rotor'
model = pyc.FeaModel(model_name)
model.set_units('m') # this sets dist units to meters, labels our consistent units
# this sets dist units to meters, labels our consistent units
model.set_units('m')

# set whether or not to show gui plots
show_gui = True
if '-nogui' in sys.argv:
show_gui = False
# set element shape
eshape = 'quad'
if '-tri' in sys.argv:
eshape = 'tri'

# problem + geometry constants
rpm = 1000 # rotor speed in rpm
Expand All @@ -32,11 +44,15 @@
flowpath_ax = (web_width + 2*arm_length - airfoil_width) / 2.0

# these are deltas
disk_loop = [[disk_ht,0],[diskramp_rad,diskramp_ax],[web_ht,0,],[0,-arm_length],
[arm_th,0],[0,flowpath_ax],[0,airfoil_width],[0,flowpath_ax],
[-arm_th,0],[0,-arm_length],[-web_ht,0],[-diskramp_rad,diskramp_ax],
disk_loop = [[disk_ht,0],[diskramp_rad,diskramp_ax],
[web_ht,0,],[0,-arm_length],
[arm_th,0],[0,flowpath_ax],
[0,airfoil_width],[0,flowpath_ax],
[-arm_th,0],[0,-arm_length],[-web_ht,0],
[-diskramp_rad,diskramp_ax],
[-disk_ht,0],[0,-disk_width]]
airfoil_loop = [[airfoil_ht,0],[0,airfoil_width],[-airfoil_ht,0],[0,-airfoil_width]]
airfoil_loop = [[airfoil_ht,0],[0,airfoil_width],
[-airfoil_ht,0],[0,-airfoil_width]]

# make part
part = pyc.Part(model)
Expand All @@ -60,7 +76,8 @@
for [i1, i2, rad] in fillet_list:
part.fillet_lines(lines[i1], lines[i2], rad)
# view the geometry
model.plot_geometry(model_name+'_geom', pnum=False, lnum=False)
model.plot_geometry(model_name+'_geom', pnum=False, lnum=False,
display=show_gui)

# set loads and constraints
model.set_rpm(10000, part)
Expand All @@ -72,16 +89,17 @@
model.set_matl(mat, part)

# mesh model
model.set_eshape('quad', 2)
model.set_eshape(eshape, 2)
model.set_etype('axisym', 'A0')
model.set_etype('plstress', 'A1', 0.1)
model.get_item('L15').set_ediv(8)
model.get_item('L6').set_ediv(8)
model.get_item('L2').set_ediv(24)
model.get_item('L10').set_ediv(24)
model.mesh(1.0, 'gmsh') # mesh with 1.0 fineness, smaller is finer
model.plot_elements(model_name+'_elem') # plot the part elements
model.plot_constraints(model_name+'_constr')
# plot the part elements
model.plot_elements(model_name+'_elem', display=show_gui)
model.plot_constraints(model_name+'_constr', display=show_gui)

# make and solve the model
prob = pyc.Problem(model, 'struct')
Expand Down
37 changes: 26 additions & 11 deletions examples/dam-eplot.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
#!/usr/bin/env python3
import pycalculix as pyc
import math
import sys

import pycalculix as pyc

# We'll be modeling a masonry gravity dam, the Beetaloo dam in Australia
# This time, we'll include multiple time steps, and element plotting
# make model
model_name = 'dam-eplot'
model = pyc.FeaModel(model_name)
model.set_units('m') # this sets dist units to meters, labels our consistent units
# this sets dist units to meters, labels our consistent units
model.set_units('m')

# set whether or not to show gui plots
show_gui = True
if '-nogui' in sys.argv:
show_gui = False
# set element shape
eshape = 'quad'
if '-tri' in sys.argv:
eshape = 'tri'

# Problem constants
grav = 9.81 # m/s^2
Expand Down Expand Up @@ -39,7 +51,7 @@
for [x,y] in pts_ft_air:
[x,y] = [x*0.3048,y*0.3048] # conversion to metric
[L1,p1,p2] = part.draw_line_to(x, y)
air_lines.append(L1)
air_lines.append(L1)
# make the two arcs
pts_ft_arcs = [ [[22,73],[146,208]], [[14,98],[41,93]] ]
for [[x,y],[xc,yc]] in pts_ft_arcs:
Expand All @@ -54,28 +66,31 @@
[L1,p1,p2] = part.draw_line_to(x, y)
air_lines.append(L1)
part.draw_line_to(0, 0)
model.plot_geometry(model_name+'_geom') # view the points, lines, and areas
# view the points, lines, and areas
model.plot_geometry(model_name+'_geom', display=show_gui)

# set part material
mat = pyc.Material('concrete')
mat.set_mech_props(2300, 30000*(10**6), 0.2)
model.set_matl(mat, part)

# set the element type, line division, and mesh the database
model.set_eshape('quad', 2)
model.set_eshape(eshape, 2)
model.set_etype('plstrain', part, thickness)
model.set_ediv('L8',2)
model.mesh(0.5, 'gmsh') # mesh with 1.0 or less fineness, smaller is finer
model.plot_elements(model_name+'_elem') # plot the part elements
# mesh with 1.0 or less fineness, smaller is finer
model.mesh(0.5, 'gmsh')
model.plot_elements(model_name+'_elem', display=show_gui) # plot the part elements

# set loads and constraints
model.set_load('press', air_lines, press_atm)
model.set_fluid_press(water_lines, dens_water, grav, water_ht_m, press_atm)
model.set_fluid_press(water_lines, dens_water, grav, water_ht_m,
press_atm)
model.set_gravity(grav, part)
model.set_constr('fix', part.bottom, 'x')
model.set_constr('fix', part.bottom, 'y')
model.plot_pressures(model_name+'_press_1')
model.plot_constraints(model_name+'_constr')
model.plot_pressures(model_name+'_press_1', display=show_gui)
model.plot_constraints(model_name+'_constr', display=show_gui)

# make model and solve it
prob = pyc.Problem(model, 'struct')
Expand All @@ -87,7 +102,7 @@
fields = fields.split(',')

for time in prob.rfile.steps:
prob.rfile.set_time(time)
prob.rfile.set_time(time)
for field in fields:
fname = '%s_%i_%s' % (model_name, int(time), field)
# nodal plotting
Expand Down
Loading

0 comments on commit 499a262

Please sign in to comment.