pycalculix package¶
Submodules¶
pycalculix.base_classes module¶
This module stores base classes and functions.
-
pycalculix.base_classes.
RESFILEDS
¶ stores results fields under results type
- key (str):
- ‘displ’: displacement
- ‘stress’: stress
- ‘strain’: strain
- ‘force’: force
- value (list):
- ‘displ’ = ‘ux’,’uy’,’uz’,’utot’
- ‘stress’ = ‘Sx’,’Sy’,’Sz’,’Sxy’,’Syz’,’Szx’,’Seqv’,’S1’,’S2’,’S3’
- ‘strain’ = ‘ex’,’ey’,’ez’,’exy’,’eyz’,’ezx’,’eeqv’,’e1’,’e2’,’e3’
- ‘force’ = ‘fx’,’fy’,’fz’
Type: dict
-
pycalculix.base_classes.
FIELDTYPE
¶ the inverse dict of RESFIELDS
For example: key ‘ux’ –> value: ‘displ’
Type: dict
-
class
pycalculix.base_classes.
Idobj
[source]¶ Bases:
object
Makes an object that stores an id number.
This is a base class for nodes, lines, areas etc.
-
id
¶ the unique id number for the item
Type: int
-
-
class
pycalculix.base_classes.
Itemlist
[source]¶ Bases:
list
Makes a custom list used to store lists of non-mesh items.
non-mesh items = Point, Line, Arc, Area, Part, Components, Loads This class allows us to automatically assign id numbers to items in the list. Thes id numbers are needed when we send geometry out for meshing. All instances of this class start as empty lists.
-
class
pycalculix.base_classes.
Meshlist
[source]¶ Bases:
list
Makes a custom list used to store lists of nodes and elements.
All instances of this class start as empty lists.
-
pycalculix.base_classes.
chunk_list
(inlist, size)[source]¶ Returns a list of lists where each list <= size length.
Splits inlist into list of lists where each child list len <= size.
Parameters: - inlist (list) – list that we want cut into smaller lists
- size (int) – max length of small lists returned
Returns: list of list where each child list <= size length
Return type: res (list of lists)
-
pycalculix.base_classes.
listify
(items)[source]¶ Returns a list of items. If items is an object it puts it in a list.
If a list is passed, it returns the list without changing it. If an object is passed, it returns a list with the object in it.
Parameters: items (object or list) – item or list to convert to a list
pycalculix.cadimporter module¶
This module stores the CadImporter class, which is used to load CAD parts.
-
class
pycalculix.cadimporter.
CadImporter
(feamodel, fname='', layer=-1, swapxy=False, scale='')[source]¶ Bases:
object
Makes an object which can import cad parts.
Parameters: - feamodel (FeaModel) – model that we want to import parts into
- layer (int) – layer to import, all entities will be flattened to one plane. -1 mean all layers, any other number is a specific layer
- swapxy (bool) – True rotates the part from x axial to y axial
- scale (str) –
string telling the unit conversion scalar
- Any option of ‘fromunit-tounit’ using the below units
- mm, m, in, ft
- Examples ‘mm-m’ ‘m-in’ ‘ft-mm’ ‘in-ft’
- Default value is ‘’ and does not apply a scale factor
-
__fname
¶ file we want to import
Type: str
-
__layer
¶ layer to import
Type: int
-
__swapxy
¶ If true, swap part from xy to yx orientation
Type: bool
pycalculix.components module¶
This module defines the Component class, which is used to make components.
Components are collections that loads are applied to.
-
class
pycalculix.components.
Component
(item_list, ctype, cname='')[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a component to store loads, boundary conditions, matl, thickness.
A component must store a list of items where the type is identical for all items.
Parameters: - item_list (list) – list of items to store
- ctype (str) –
type of component. Options:
- ’nodes’: all element nodes (corner and mid-side)
- ’n1’: element corner nodes
- ’faces’: faces
- ’elements’: elements
- cname (str) – component name
-
ccx
()[source]¶ Writes a component for Calculix ccx solver.
Returns a list strings, where each item is a line to write to a Calculix .inp text file.
Note
Only node and element components should use this.
-
set_name
(name)[source]¶ Set the component name to the passed name.
Parameters: name (str) – passed name, component name is changed to this
pycalculix.connectors module¶
This module stores connector classes, like Contact.
-
class
pycalculix.connectors.
Contact
(master_comp, slave_comp, surf_int, surf_to_surf=True)[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a contact which will be between lines which have faces on them.
Parameters: - master_comp (Component) – component of master element faces
- slave_comp (Component) – component of slave element faces
- surf_int (SurfaceInteraction) – object which stores closure behavior
- surf_to_surf (bool) – if True surface to surface is used, if False node to surface is used
-
name
¶ Contact name.
-
class
pycalculix.connectors.
SurfaceInteraction
(int_type, *args)[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a surface interaction object.
Parameters: - int_type (str) –
interaction type
- ’EXPONENTIAL’
- ’LINEAR’
- *args –
following arguments
- int_type = ‘EXPONENTIAL’
- c0, then p0 must be passed
- int_type = ‘LINEAR’
- k must be passed
-
name
¶ SurfaceInteraction name.
- int_type (str) –
pycalculix.environment module¶
This module sets the dpi and the paths to gmsh, ccx, and cgx.
-
pycalculix.environment.
DPI
¶ if high dpi windows 8 monitor value is set, otherwise value is None.
Type: None or float
-
pycalculix.environment.
CCX
¶ path to Calculix ccx, the sovler.
Type: str
-
pycalculix.environment.
CGX
¶ path to Calculix cgx, the preprocessor/postprocessor/mesher.
Type: str
-
pycalculix.environment.
GMSH
¶ path to the Gmsh mesher.
Type: str
-
class
pycalculix.environment.
OSVERSIONINFOEXW
[source]¶ Bases:
_ctypes.Structure
Returns object w/ attributes that will identify window os version
-
dwBuildNumber
¶ Structure/Union member
-
dwMajorVersion
¶ Structure/Union member
-
dwMinorVersion
¶ Structure/Union member
-
dwOSVersionInfoSize
¶ Structure/Union member
-
dwPlatformId
¶ Structure/Union member
-
szCSDVersion
¶ Structure/Union member
-
wProductType
¶ Structure/Union member
-
wReserved
¶ Structure/Union member
-
wServicePackMajor
¶ Structure/Union member
-
wServicePackMinor
¶ Structure/Union member
-
wSuiteMask
¶ Structure/Union member
-
pycalculix.feamodel module¶
This module stores the FeaModel class.
This class is the highest level object in a pycalculix program. It stores all parts, loads, constraints, mesh, problem, and results_file objects.
-
class
pycalculix.feamodel.
FeaModel
(model_name, ccx=None, cgx=None, gmsh=None)[source]¶ Bases:
object
Makes a FeaModel instance.
Parts, area, lines, arcs, points, nodes, elements, faces, models, components, and loads are stored in this object.
Parameters: - model_name (str) – project name for this FeaModel, this is a file prefix
- ccx (None or str) – path to Calculix ccx solver, pass this when you want to overwite the default program location. None means the default envionment.CCX is used.
- cgx (None or str) – path to Calculix cgx mesher, pass this when you want to overwite the default program location. None means the default envionment.CGX is used.
- gmsh (None or str) – path to gmsh mesher, pass this when you want to overwite the default program location. None means the default envionment.GMSH is used.
-
fname
¶ FeaModel project file name prefix
Type: str
-
loads
¶ a dictionary of loads
Key (float): the load time pointloads[time] = list of loads for that time stepSee method set_time to change the current time.Time = 0.0 stores constant loads, such as:material, thicknessType: dict
-
eshape
¶ element shape
- ‘quad’: quadrilateral elements (Default)
- ‘tri’: triangle elements
Type: str
-
eorder
¶ element order, 1 or 2
- 1: elements meshed with corner nodes only
- 2: (Default) elements meshed with corner and midside nodes
Type: int
-
faces
¶ list of all element faces, includes non-exterior ones
Type: list
-
view
¶ currently selected items
-
parts
list of selected parts
-
areas
list of selected areas
-
lines
list of selected signed lines or arcs
-
points
list of selected points
-
elements
list of selected elements
-
faces
list of selected faces
-
nodes
list of selected nodes
Type: Selector -
-
time
¶ current model time value, defaults to 1.0
Type: float
-
units
¶ a dict to store units for different fields
- Keys:
- ‘displ’: displacement or location
- ‘force’: force
- ‘stress’: stress
- ‘temp’: temperature
- ‘density’: density (mass/volume)
- ‘time’: time
Returns: Text string describing the units for the given key field. See the set_units method.
For example when units have been set to metric, the below values are returned.
- ’dist’ –> ‘m’
- ’density’ –> ‘kg/(m^3)’
- ’time’ –> ‘s’
Type: dict
-
get_item
(item)[source]¶ Returns an item given a string identifying the item.
Parameters: item (str) – ‘A0’ or ‘P0’ or ‘L0’ etc.
-
get_items
(items)[source]¶ Returns a list of correctly typed items.
Input can be a single string or item, or a list of strings identifying items.
-
get_units
(*args)[source]¶ Returns units for the passed arguments. Accepts and returns a list of strings.
- Options for inputs:
- ‘dist’
- ‘displ’ (same units as ‘dist’)
- ‘force’
- ‘stress’
- ‘temp’
- ‘density’
- ‘time’
-
make_matl
(name)[source]¶ Makes and returns a new material.
Parameters: name (str) – the material’s name
-
make_problem
(problem_type='struct', parts='all')[source]¶ Makes and returns a new problem, which can be solved.
Parameters: - problem_type (str) – problem type, options: ‘struct’: structural
- parts (str Part or list of Part) –
Parts the model will analyze.
- Options:
- ’all’: add all parts. This is the default.
- Part: add the single part
- list of Part: add these parts
-
mesh
(size=1.0, meshmode='fineness', mesher='gmsh')[source]¶ Meshes all parts.
Parameters: - size (float) –
- if meshmode == ‘fineness’ (default):
- mesh size is adapted to geometry size
- set size = 0.0001 - 1.0, to define how fine the mesh is.
- Low numbers are very fine, higher numbers are coarser.
- if meshmode == ‘esize’:
- element size is kept constant
- choose it depending on geometry size
- it should be reduced e.g. at arcs with small radius, by calling line.esize function
- meshmode (str) –
- ‘fineness’: adapt mesh size to geometry
- ’esize’: keep explicitly defined element size
meshmode is changed to ‘esize’ is used if esize property is set to points or lines
- mesher (str) –
the mesher to use
- ’gmsh’: mesh with Gmsh, this is reccomended, it allows holes
- ’cgx’: mesh with Calculix cgx, it doesn’t allow holes
- size (float) –
-
plot_areas
(fname='', display=True, title='Areas', label=True)[source]¶ Plots selected areas
Defaults to displaying labels on: areas and filling all part areas.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
- title (str) – the plot’s title
- label (bool) – if True all areas will be labeled
-
plot_constraints
(fname='', display=True)[source]¶ Plots the constraints on the passed part(s) or selected items.
This is an element and node plot, with arrows showing displacement constraints.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
-
plot_elements
(fname='', display=True, title='Elements', enum=False, nshow=False, nnum=False)[source]¶ Plots the selected elements.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown
- title (str) – the plot’s title
- enum (bool) – if True element numbers are plotted
- nshow (bool) – True=plot nodes, False=don’t plot them
- nnum (bool) – if True node numbers are plotted
-
plot_geometry
(fname='', display=True, title='Geometry', pnum=True, lnum=True, anum=True, afill=True)[source]¶ Plots selected geometry items: areas, lines, points.
Defaults to displaying labels on: areas, lines, and points, and filling in the areas.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
- title (str) – the plot’s title
- pnum (bool) – if True all Point objects will be labeled
- lnum (bool) – if True all Line and Arc objects will be labeled
- anum (bool) – if True all Area objects will be labeled
- afill (bool) – if True all Area objects will be filled
-
plot_lines
(fname='', display=True, title='Lines', label=True)[source]¶ Plots selected lines and arcs
Defaults to displaying labels on: lines and arcs
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
- title (str) – the plot’s title
- label (bool) – if True all lines and arcs will be labeled
-
plot_multiple
(fname='', display=True, title='', styledict={'items': ['points, lines, areas'], 'labels': ['points', 'lines', 'areas', 'parts']})[source]¶ Plots items of type styledict[‘items’], labels styledict[‘labels’]
Only the items currently selected will be plotted.
-
plot_nodes
(fname='', display=True, title='Nodes', nnum=False)[source]¶ Plots the selected nodes.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown
- title (str) – the plot’s title
- nnum (bool) – if True node numbers are plotted
-
plot_parts
(fname='', display=True, title='Parts', label=True)[source]¶ Plots selected parts
Defaults to displaying labels on: parts and filling all part areas.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
- title (str) – the plot’s title
- label (bool) – if True all Part objects will be labeled
-
plot_points
(fname='', display=True, title='Points', label=True)[source]¶ Plots selected points
Defaults to displaying labels on: points
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
- title (str) – the plot’s title
- label (bool) – if True all points will be labeled
-
plot_pressures
(fname='', display=True)[source]¶ Plots the load step pressures on the passed part(s) or selected elements.
This is an element plot, with arrows showing pressure magnitude and directions.
Parameters: - fname (str) – png image file prefix, if given, image will be saved
- display (bool) – if True, interactive plot will be shown, if False plot will not be shown. Default = True
-
register
(item)[source]¶ Adds an item to the feamodel.
Item is added to the correct list and its id is updated. Allowed Items:
- Point
- Line
- Arc
- SignLine
- SignArc
- LineLoop
- Area
- Part
-
scale
(unitstr, point_first=None, point_last=None)[source]¶ Scales the points from [point_first, …, point_last] using unitstr
If point_first and point_last are both None, all points are scaled.
Parameters: - unitstr (str) –
string scalar ‘fromunit-tounit’ using the below units:
- mm, m, in, ft
- Examples ‘mm-m’ ‘m-in’ ‘ft-mm’ ‘in-ft’
- Default value is ‘’ and does not apply a scale factor
- point_first (Point or None or str) – the first point to scale, string point names may be passed
- point_last (Point or None or str) – the last point to scale, string point names may be passed
- unitstr (str) –
-
set_constr
(ltype, items, axis, val=0.0)[source]¶ Sets a displacement constraint on the passed item(s).
Parameters: - ltype (str) –
‘fix’ or ‘displ’
- ’fix’: val arg should not be passed
- ’displ’: val arg must be passed
- items (str, SignLine, SignArc, Point or list) –
item(s) to apply the constraint on
- str: this string must be a line or point name
- SignLine or SignArc: the constraint will be applied
- to this item
- Point: the constraint will be applied on this item
- list of SignLine or SignArc: the constraint will be appplied
- on these
- list of Point: the constraint will be appplied on these
- list of str names: pass line or point names, constr
- applied on them
- axis (str) – load axis, ‘x’ or ‘y’
- val (float) – displacement value, defaults to 0.0, only needs to be set when ltype = ‘displ’
- ltype (str) –
-
set_contact_linear
(master_lines, slave_lines, kval, many_si=False)[source]¶ Sets contact between master and slave lines.
Slave lines are on the more compliant or more curved object.
Parameters: - master_lines (list) – list of SignLine or SignArc
- slave_lines (list) – list of SignLine or SignArc
- kval (float) – stiffness, 5 to 50 times the youngs modulus of the touching matl
- many_si (bool) – True, make unique surface interaction for every contact False, use existing surface interaction if we can
-
set_eshape
(eshape='quad', eorder=2)[source]¶ Sets the element shape and order to use when meshing the model.
Parameters: - eshape (str) –
element shape
- ’quad’: quadrilaterials
- ’tri’: triangles
- eorder (int) –
element order, default=2
- 1: corner nodes only (3 and 4 noded elements)
- 2: corder nodes and midside nodes (6 and 8 noded elements)
- eshape (str) –
-
set_etype
(etype, items, thick=None)[source]¶ Sets the element type, and thickness on areas or parts.
Parameters: - etype (str) –
element type
- ’plstress’: plane stress
- ’plstrain’: plane strain
- ’axisym’: axisymmetric
- items (str or Area or Part or list) –
set element type on these
- str: string name of Area or Part item. Example: ‘A0’, ‘PART0’
- Area: set element type on the elements in this area
- Part: set element type on the elements in this part
- list of Area or Part: set element type on their elements
- thick (float or None) –
element thickness
- None: default, used for axisymmetric element type
- float: thickness value to use for plane stress or plane
- strain elements
- etype (str) –
-
set_fluid_press
(items, rho, g, xo, po)[source]¶ This sets a fluid presure load on items.
This fluid pressure is dependednt on the x axis. g must be positive.
- P = f(x)
- P(xo) = po
- P(x) = po + rho*g*(xo - x)
Parameters: - items (str or Line or Arc or list) –
items to set pressure on
- str: string name of Line or Arc item, for example ‘L0’
- Line or Arc: set presssure on this
- list or Line or Arc: set pressure on these
- rho (float) – fluid density in mass/volume
- g (+float) – gravity in dist/(t^2), MUST BE POSITIVE
- xo (float) – sea level height, MUST BE POSITIVE
- po (float) – sea level pressure, MUST BE POSITIVE
-
set_gravity
(grav, items)[source]¶ Sets gravity on the elements in items.
Assumes gravity acts in the -x direction with magnitude grav.
Parameters:
-
set_load
(ltype, items, lval, ldir=None)[source]¶ Sets a pressure or force load on line(s).
The force load is divided by the number of nodes and applied on each node.
The pressure load is applied to the child faces under the line. Positive is compression, negative is tension.
Parameters: - ltype (str) – ‘press’ or ‘force’
- items (str or Line or Arc or list) –
items to set load on
- str: string name of Line or Arc item, for example ‘L0’
- Line or Arc: set load on this
- list or Line or Arc: set load on these
- lval (float) –
load value.
- For ltype = ‘press’ this is in force/area units
- For ltype = ‘force’ this is in force units
- ldir (None or str) –
load direction. Defaults to None
- str: when ltype=’load’, we need to set ldir to ‘x’ or ‘y’
- None: when ltype=’press’
-
set_time
(time)[source]¶ Sets the time in the FeaModel (preprocessor).
This time is used when setting loads.
Parameters: time (float) – the time to set
-
set_units
(dist_unit='m', cfswitch=False)[source]¶ Sets the units that will be displayed when plotting.
Picks a unit set based on the passed distance unit. That unit set is printed to the console when set. Defaults to MKS units (meter-kilogram-second)
Distance Force Stress Temperature Density Time ‘m’ ‘N’ ‘Pa’ ‘K’ ‘kg/(m^3)’ ‘s’ ‘mm’ ‘N’ ‘MPa’ ‘K’ ‘tonne/(mm^3)’ ‘s’ ‘in’ ‘lbf’ ‘psi’ ‘R’ ‘slinch/(in^3)’ ‘s’ ‘ft’ ‘lbf’ ‘psf’ ‘R’ ‘slug/(ft^3)’ ‘s’ See get_units method or returning text strings based on unit types.
Parameters: - dist_unit (str) –
string of distance unit. Options:
- ’m’: meter
- ’mm’: milimeter
- ’in’: inch
- ’ft’: foot
- cfswitch (bool) –
Celsius/Fahrenheit temperature switch. Default is False.
If True, this switches temperature from K–>C or from R–>F Default keeps units as shown in above table.
- dist_unit (str) –
pycalculix.geometry module¶
This module stores geometry classes, which are used to make parts.
-
class
pycalculix.geometry.
Arc
(start_pt, end_pt, actr)[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes an arc from points start_pt to end_pt about center actr.
Arcs should be 90 degrees maximum.
Parameters: -
points
¶ list of the line’s points [start_pt, end_pt]
Type: list of Point
-
allpoints
¶ [start_pt, end_pt, actr]
Type: list of Point
-
radius
¶ radius of the arc
Type: float
-
concavity
¶ - ‘concave’: concave arc
- ‘convex’: convex arc
Type: str
-
ediv
¶ number of elements on arc
Type: None or int
-
nodes
¶ a list of meshed nodes on the line
Type: list of Node
-
edge
¶ True if arc is a non-shared edge in an area
Type: bool
-
signlines
¶ list of SignArc that use this Arc
Type: list
-
allpoints
Returns all points including arc center
-
areas
¶ Returns all areas that signlines use.
-
coincident
(pt)[source]¶ Checks to see if pt is on the arc.
Parameters: pt (Point) – input point to check Returns: True if pt on arc or False if not Return type: bool
-
get_ang
()[source]¶ Returns angle from beginning to end of arc from arc ctr in degrees
Notes
Answer is between 180 and -180 Positive is concave Negative is convex
-
get_ang_rad
()[source]¶ Returns angle from beginning to end of arc from arc ctr in rad
Notes
Answer is between pi and -pi Positive is concave Negative is convex
-
get_perp_vec
(pt)[source]¶ Returns vector perpendicular to current arc.
- Right hand rule is used:
- X+ is the direction of the arc from start to end. Z+ is out of the page Y+ is the direction of the perpendicular vector
Parameters: pt (Point) – point on arc where we want the perpendicular vector Returns: perpendicular vector Return type: resv (Point)
-
get_pt_at
(nondim)[source]¶ Returns point on arc between start and end point at nondim dist.
Parameters: nondim (float) – distance between start and end point, 0=start, 1=end Returns: requested point on arc Return type: res (Point)
-
get_tan_vec
(point)[source]¶ Returns vector tangent to the current arc.
Vector points from the passed point to a unit location further away.
Parameters: point (Point) – start point Returns: vector that is tangent to the current line Return type: resv (Point)
-
intersects
(other)[source]¶ Checks if other line intersects this arc.
Parameters: other (Line or Arc) – other line to check Returns: Point: intersection point None: None if lines don’t intersect Return type: Point or None
-
pt
(ind)[source]¶ Returns the start or end point of the arc.
Parameters: ind (int) – index of the point we want, 0=start, 1=end Returns: requested Point Return type: Point
-
set_ediv
(ediv)[source]¶ Sets the number of element divisions on the arc when meshing.
Parameters: ediv (int) – number of required elements on this arc
-
set_esize
(esize)[source]¶ Sets the size of mesh elements on the arc when meshing.
Parameters: esize (float) – size of mesh elements on this arc
-
set_pt
(ind, point)[source]¶ Update the arc’s point at ind to the new point.
Parameters: - ind (int) – index of the point we’re updating, 0=start, 1=end
- point (Point) – new point we are assigning to Line
-
-
class
pycalculix.geometry.
Area
(part, line_list=[])[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes an area.
Area is closed in a clockwise direction.
Parameters: - part (Part) – parent Part
- line_list (list) – list of Lines and Arcs that close the area
-
closed
¶ True if closed, False if not
Type: boolean
-
signlines
¶ list of signed lines or arcs that define the area
Type: list
-
lines
¶ a list of all the lines that make the area, includes hole lines
Type: list
-
points
¶ a list of all points making the area, excludes arc centers
Type: list
-
allpoints
¶ a list of all points, includes arc centers
Type: list
-
holepoints
¶ a list of hole points, excludes arc centers
Type: list
-
matl
¶ the material fo the area
Type: Matl
-
etype
¶ element type of area. Options are: ‘plstress’: plane stress ‘plstrain’: plane strain ‘axisym’: axisymmetric
Type: str
-
area
¶ in-plane part area (ballpark number, arcs not calc right)
Type: double
-
holes
¶ list of LineLoop of signlines
Type: list
-
nodes
¶ child mesh nodes that are in the area
Type: list
-
elements
¶ child elements that are in the area
Type: list
-
add_hole_sline
(signline)[source]¶ Adds signline to the area hole definition.
Line is added to the end of the lines list. Area is closed if needed.
Returns: boolean telling if the hole was closed Return type: closed (bool)
-
add_sline
(signline)[source]¶ Adds signline to the area definition.
SignLine is added to the end of the lines list. Area is closed if needed.
-
allpoints
Returns a list of all points under this area; includes arc centers.
-
calc_area_center
()[source]¶ Calculates and returns the area and centroid Point.
Returns: [area, Point] Return type: list
-
contains_point
(point)[source]¶ Returns bool telling if pt is inside the area.
Parameters: pt (Point) – point we are checking Returns: True if in this area False if not Return type: contains (bool)
-
holepoints
Returns a list of all points in this area’s holes.
-
label
(axis)[source]¶ Labels the area on a Matplotlib axis
Parameters: axis (Matplotlib Axis) – Matplotlib Axis
-
line_from_startpt
(pt)[source]¶ Returns the signline in the area that start at the passed pt.
Parameters: pt (Point) – the start point of the line one wants Returns: Returns None if no line is found, otherwise the correct line orarc which starts with pt will bereturned.Return type: match (None or SignLine or SignArc)
-
line_insert
(lgiven, lnew, after=True)[source]¶ Inserts line lnew before or after the given line.
Parameters: Returns: True if succeeded, False if failed
Return type: bool
-
lines
Returns a list of all Line and Arc under this area.
-
plot
(axis, label=True, color='yellow')[source]¶ Plots the area on a Matplotlib axis.
Parameters: - axis (Matplotlib axis) – Matplotlib axis
- label (bool) – if True, label area
-
points
Returns a list of all points under this area; excludes arc centers.
-
set_esize
(esize)[source]¶ Sets the size of mesh elements on the area when meshing.
Parameters: esize (float) – size of mesh elements on this area
-
set_etype
(etype)[source]¶ Sets the area etype.
Sets the ccxtype on elements if they have been assigned to this area.
Parameters: etype (str) – element type ‘plstress’ plane stress ‘plstrain’: plane strain ‘axisym’: axisymmetric
-
signlines
Returns a list of all SignLine and SignArc under this area.
-
class
pycalculix.geometry.
Line
(start_pt, end_pt)[source]¶ Bases:
pycalculix.base_classes.Idobj
Stores a line from points start_pt to end_pt.
Parameters: -
points
¶ list of the line’s points [start_pt, end_pt]
Type: list of Point
-
ediv
¶ number of elements on the line
Type: None or float
-
nodes
¶ a list of meshed nodes on the line
Type: list of Node
-
edge
¶ True if line is a non-shared edge in an area
Type: bool
-
signlines
¶ list of SignLine that use this Line
Type: list
-
allpoints
¶ Returns all line defining points.
-
arc_tang_intersection
(point, mag)[source]¶ Returns an intersection point on this line of an arc at center point
Parameters: - point (Point) – arc center point
- mag (float) – passed radius distance from the arc center to the line
Returns: Point: the intersection point None: returns None if no intersection point exists
Return type: newpt (Point or None)
-
areas
¶ Returns all areas that signlines use.
-
coincident
(point)[source]¶ Checks to see if point is on the line.
Parameters: point (Point) – input point to check Returns: True if point on line or False if not Return type: bool
-
get_abc
()[source]¶ Returns a list of abc terms for a line definition.
ax + by + c = 0
Returns: list of the above line terms Return type: [a, b, c]
-
get_perp_vec
(point=None)[source]¶ Returns vector perpendicular to current line.
Vector is created by rotating the current line ccw 90 degrees around the start point.
Parameters: point (Point) – defaults to None, unused for Line, used for Arc Returns: vector that is perpendiculat to the current line Return type: lvect (Point)
-
get_tan_vec
(point)[source]¶ Returns vector tangent to the current line.
Vector points from the passed point to a unit location further away.
Parameters: point (Point) – start point Returns: vector that is tangent to the current line Return type: lvect (Point)
-
intersects
(other)[source]¶ Checks if other line intersects this line.
Parameters: other (Line, Arc, Signline, SignArc) – other line to check Returns: Point: intersection point None: None if lines don’t intersect Return type: Point or None
-
offset
(dist)[source]¶ Returns a new line offset from the dirrent line by value dist.
Right hand rule is followed assuming x is the origina line. Z points out of page. Y is the direction of line offset.
Parameters: dist (float) – distance to offset the new line by Returns: new Line which is offset from self by dist Return type: tmpline (Line)
-
pt
(ind)[source]¶ Returns the start or end point of the line.
Parameters: ind (int) – index of the point we want, 0=start, 1=end Returns: requested Point Return type: Point
-
set_ediv
(ediv)[source]¶ Sets the number of element divisions on the line when meshing.
Parameters: ediv (int) – number of required elements on this line
-
set_esize
(esize)[source]¶ Sets the size of mesh elements on the line when meshing.
Parameters: esize (float) – size of mesh elements on this line
-
-
class
pycalculix.geometry.
LineLoop
(items=[], hole_bool=False, parent=None)[source]¶ Bases:
list
Makes a LineLoop, which stores multiple Line/Arc or SignLine/SignArc.
Parameters: - items (list) – Line or Arc or SignLine or SignArc
- hole_bool (bool) – True if hole, False otherwise
- parent (Area or None) – parent Area, defaults to None
-
closed
¶ True if closed
Type: bool
-
area
¶ the loop’s area, can be pos or neg. Pos = cw, neg = ccw
Type: float
-
hole
¶ True if loop is a hole
Type: bool
-
ccw
¶ True if loop is counter-clockwise
Type: bool
-
append
(item)[source]¶ Adds an item to this LineLoop
Parameters: item (SingArc or SignLine) – item to add to the list
-
area
Returns the loop’s signed area.
Returns 0 if not closed. Pos = cw, neg = ccw
Formula from: http://mathworld.wolfram.com/PolygonArea.html
-
ccw
Returns bool telling if the area is closed and clockwise.
-
center
Returns None or a Point at the line loop’s center.
-
closed
Returns True if Closed, False if not.
-
contains_point
(point)[source]¶ Returns bool telling if pt is inside the LineLoop.
Parameters: pt (Point) – point we are checking Returns: True if in this area False if not Return type: contains (bool)
-
insert
(index, item)[source]¶ Inserts a SignLine or SignArc item into this LineLoop
Parameters: item (SingArc or SignLine) – item to insert
-
remove
(item)[source]¶ Removes an SignLine or SignArc item from this LineLoop
Parameters: item (SignArc or SignLine) – item to remove
-
class
pycalculix.geometry.
Point
(x, y, z=0)[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a point or vector.
Parameters: - x (float) – vertical coordinate of point
- y (float) – horizontal coordinate of point
- z (float) – in-page coordinate of point, defaults to zero
-
x
¶ vertical coordinate of point
Type: float
-
y
¶ horizontal coordinate of point
Type: float
-
z
¶ in-page coordinate of point, defaults to zero nodes (Node): a list of nodes in a mesh at this point. List length is 1.
Type: float
-
nodes
¶ list of nodes under point
Type: list
-
lines
¶ set of lines which use this point
Type: set
-
arc_center
¶ True if this point is an arc center
Type: bool
-
ang_bet_deg
(other)[source]¶ Returns angle between self and other vector in degrees.
Assumes vectors start at 0,0
Parameters: other (Point) – passed vector Returns: degrees between self vector and other vector Return type: angle (float)
-
ang_bet_rad
(other)[source]¶ Returns angle between self and other vector in radians.
Assumes vectors start at 0,0
Parameters: other (Point) – passed vector Returns: radians between self vector and other vector Return type: angle (float)
-
label
(axis)[source]¶ Labels the point on a Matplotlib axis.
Parameters: axis (Matplotlib Axis) – Matplotlib Axis
-
plot
(axis, label=True)[source]¶ Plots the point on the passed matplotlib axis.
Parameters: - axis (Matplotlib axis) – plate to plot the point
- pnum (bool) – True turns on point labeling
-
class
pycalculix.geometry.
SignArc
(parent_line, sign)[source]¶ Bases:
pycalculix.geometry.Arc
,pycalculix.base_classes.Idobj
Makes a signed arc.
-
sign
¶ 1 = positive, or -1 = negative
Type: int
-
nodes
¶ nodes on the arc
Type: list
-
faces
¶ list of element faces
Type: list
-
n1
¶ list of first order nodes on line
Type: list
-
actr
¶ Return the arc center.
-
concavity
¶ Return the arc’s concavity ‘concave’ or ‘convex’
-
edge
¶ Returns a bool saying if this is an edge line.
-
label
(ax)[source]¶ Labels the arc on the matplotlib ax axis.
Parameters: ax (Matplotlib axis) – Matplotlib axis
-
midpt
¶ Return the mid point.
-
nodes
Gets the line nodes.
-
plot
(ax, label=True)[source]¶ Draws and labels the arc onto the passed Matplotlib axis.
Parameters: - ax – Matplotlib axis
- label (bool) – if True, label the arc
-
points
¶ Return a list of the arc’s points [pstart, pend]
-
radius
¶ Return the arc radius.
-
-
class
pycalculix.geometry.
SignLine
(parent_line, sign)[source]¶ Bases:
pycalculix.geometry.Line
,pycalculix.base_classes.Idobj
Makes a signed line.
-
sign
¶ 1 = positive, or -1 = negative
Type: int
-
faces
¶ list of element faces
Type: list
-
n1
¶ list of first order nodes on line
Type: list
-
nodes
¶ nodes on the line
Type: list
-
edge
¶ Returns a bool saying if this is an edge line.
-
label
(ax)[source]¶ Labels the line on the matplotlib ax axis.
Parameters: ax (Matplotlib axis) – Matplotlib axis
-
midpt
¶ Returns the mid point.
-
nodes
Gets the line nodes.
-
plot
(ax, label=True)[source]¶ Draws and labels the line onto the passed Matplotlib axis.
Parameters: - ax (Matlotlib axis) – Matplotlib axis
- label (bool) – if True label the line
-
points
¶ Returns a list of the line’s points [pstart, pend]
-
pt
(index)[source]¶ Returns the point at the start or end of the line.
Parameters: index (int) – 0 = start point, 1 = end point
-
pycalculix.installer module¶
-
pycalculix.installer.
add_remove_dll_links
(folder_dlls, folder_dll_links, add=True)[source]¶ Finds all dlls in folder_from and adds hard links to them in folder_to Or removes the hard links if add=False
-
pycalculix.installer.
find_brew_binary_location
(package_folder, search_string)[source]¶ Finds the location of a binary installed by homebrew
-
pycalculix.installer.
get_direct_url
(url, headers)[source]¶ Gets the zip direct download link from the project download page
-
pycalculix.installer.
href_from_link_text
(url, headers, link_text)[source]¶ Returns the url for a link with link_text description, if this function fails, it raises an error with tells the users a link which creates an issue on the pycalculix repo
-
pycalculix.installer.
remove_like
(search_path, name)[source]¶ Searches for files or folders matching name in search_path and deletes them
-
pycalculix.installer.
win_add_ccx
(bitsize, binaries_url, program_name)[source]¶ Installs ccx on a windows computer
pycalculix.loads module¶
This module stores load classes.
-
class
pycalculix.loads.
ConstLoad
(ltype, comp, val)[source]¶ Bases:
object
Makes a load. Many types are supported.
- Possible load types:
- forces
- displacements
- thickness (on nodes)
- matl (on elements)
- pressure (or stress on faces)
- gravity (on elements)
- rotation about an axis (on elements)
Parameters: - ltype (string) –
load type:
- ’fx’,’fy’,’fz’: force on each axis
- ’ux’,’uy’,’uz’: displacement on each axis
- ’nodal_thickness’: thickness on element nodes
- ’matl’: matl on elements
- ’press’: pressure, + is tension, - is compresion
- ’gravity’: gravity in x axis direction, - goes towards y axis
- ’radps’: radians per second rotation
- ’rpm’: rotations per minute rotation
- comp (Component) – component that the load is applied to
- val (double or Matl) – value of the load Matl is needed when setting material loads otherwise a double value is used to describe the load
-
class
pycalculix.loads.
LinearLoad
(ltype, comp, const, mult, xo, axis='x')[source]¶ Bases:
object
Makes a load which varies depending on x, y, or z location.
- Load Equation:
- Load(x) = const + mult*(xo - x)
This load is used to set water pressure, where p = po + rho*g*(xo - x) For water pressure this becomes:
- P(x) = po + (rho*g)*(xo-x)
- P(x) = po + mult*(xo-x)
- g is positive, xo > x
Parameters: - ltype (str) – load type ‘press_fluid’ is the only valid option
- comp (Component) – component that the load acts on
- const (float) – constant term in load equation
- mult (float) – mult term in the load equation
- xo (float) – xo term in the load equation
- axis (str) – axis that the load depends on ‘x’ or ‘y’ are valid options
pycalculix.material module¶
This module stores material classes.
-
class
pycalculix.material.
Material
(name)[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a linear elastic meterial.
Parameters: name (str) – a unique matl name -
- id
material id number
Type: int
-
- mechtype
defines mechanical material type: linear or non-linear material
Type: str
-
- density
density in mass/volume units
Type: float
-
- pratio
poisson’s ratio (unitless)
Type: float
-
- youngs
young’s modulus in Force/area = stress units
Type: float
-
- mechtpye
mechanical material type options: ‘linear’ or ‘nonlinear’
Type: str
-
- exponent
exponent of Ramberg-Osgood stress-strain equation
Type: float
-
- yield_stress
yield stress of material
Type: float
-
- yield_offset
yield offset of Ramberg-Osgood stress-strain equation
Type: float
-
- conductivity
thermal conductivity, Power / (distance-temp)
Type: float
-
- spec_heat
specific heat (energy/(mass-temp)
Type: float
-
- thermal_exp
a dict storing temperature dependent thermal – expansion properties
– Thermal expansion is in strain per temperature
- dict[‘data’] = zip of (temp, thermal_expansion)
- dict[‘tzero’] = the temperature zero point
Type: dict
-
set_mech_props
(density, youngs, pratio, mechtype='linear', exponent=0.0, yield_stress=0.0, yield_offset=0.0)[source]¶ Sets the mechanical properties: density, youngs, poisson_ratio.
Parameters: - density (-) – density in mass/volume units
- pratio (-) – poisson’s ratio (unitless)
- youngs (-) – young’s modulus in Force/area = stress units
- Kargs:
- mechtpye (str): mechanical material type options: ‘linear’ or ‘nonlinear’
- exponent (float): exponent of Ramberg-Osgood stress-strain equation
- yield_stress (float): yield stress of material
- yield_offset (float): yield offset of Ramberg-Osgood stress-strain equation
-
pycalculix.mesh module¶
This module stores classes that make a finite element analysis mesh.
-
class
pycalculix.mesh.
Element
(enum, ccxtype, nlist)[source]¶ Bases:
object
Makes a mesh element.
Supports 4 noded quads, 8 noded quads, 3 noded tris, 6 noded tris.
Parameters: - enum (int) – element id number
- ccxtype (str) –
ccx element type string, 4 characters long
Description: element_shape + element_order + element_type
- element_shape = ‘quad’ or ‘tri’
- ’quad’ = quadrangle
- ’tri’ = triangle
- element_order = ‘1’ or ‘2’
- ‘1’ = corner nodes only (3 or 4 noded element)
- ‘2’ = corner nodes and midside nodes (6 or 8 noded element)
- element_type = ‘plstress’ or ‘plstrain’ or ‘axisym’
- ’plstress’ = plane stress
- ’plstrain’ = plane strain
- ’axisym’ = axisymmetric
- axisymmetric
- ’CAX6’ : ‘tri2axisym’
- ’CAX3’ : ‘tri1axisym’
- ’CAX8’ : ‘quad2axisym’
- ’CAX4’ : ‘quad1axisym’
- plane stress
- ’CPS6’ : ‘tri2plstress’
- ’CPS3’ : ‘tri1plstress’
- ’CPS8’ : ‘quad2plstress’
- ’CPS4’ : ‘quad1plstress’
- plane strain
- ’CPE6’ : ‘tri2plstrain’
- ’CPE3’ : ‘tri1plstrain’
- ’CPE8’ : ‘quad2plstrain’
- ’CPE4’ : ‘quad1plstrain’
- nlist (list) – list of Node, the nodes that define the element
-
id
¶ element id number
Type: int
-
ccxtype
¶ ccx element type string, 4 characters long
Description: element_shape + element_order + element_type
- element_shape = ‘quad’ or ‘tri’
- ‘quad’ = quadrangle
- ‘tri’ = triangle
- element_order = ‘1’ or ‘2’
- ‘1’ = corner nodes only (3 or 4 noded element)
- ‘2’ = corner nodes and midside nodes (6 or 8 noded element)
- element_type = ‘plstress’ or ‘plstrain’ or ‘axisym’
- ‘plstress’ = plane stress
- ‘plstrain’ = plane strain
- ‘axisym’ = axisymmetric
- axisym
- ‘CAX6’ : ‘tri2axisym’
- ‘CAX3’ : ‘tri1axisym’
- ‘CAX8’ : ‘quad2axisym’
- ‘CAX4’ : ‘quad1axisym’
- plane stress
- ‘CPS6’ : ‘tri2plstress’
- ‘CPS3’ : ‘tri1plstress’
- ‘CPS8’ : ‘quad2plstress’
- ‘CPS4’ : ‘quad1plstress’
- plane strain
- ‘CPE6’ : ‘tri2plstrain’
- ‘CPE3’ : ‘tri1plstrain’
- ‘CPE8’ : ‘quad2plstrain’
- ‘CPE4’ : ‘quad1plstrain’
Type: str
-
node
¶ dictionary of nodes, keys are int >= 1
Type: dict
-
face
¶ dictionary of faces, keys are int >= 1
Type: dict
-
nodes
¶ list of element nodes
Type: list
-
faces
¶ list of element faces
Type: list
-
faces
Returns list of element faces.
-
get_tris
()[source]¶ Returns a list of triangles for plotting. Triangles are node ids.
CCX elements are closed in a CCW direction relative to xy normal CCX elements are closed in a CW direction relative to yx mine —> I have to draw in a clockwise direction, otherwise get error Triangles are closed in a counter clockwise (CCW) direction to yx mine http://matplotlib.org/api/tri_api.html#matplotlib.tri.Triangulation
-
nodes
Returns list of element nodes.
-
class
pycalculix.mesh.
Face
(fnum, node1, node2, element)[source]¶ Bases:
object
Makes an element face.
Parameters: -
id
¶ element face number
Type: int
-
nodes
¶ list of nodes [node1, node2]
Type: list
-
ext
¶ stores if face is external
Type: bool
-
-
class
pycalculix.mesh.
Node
(node_num, x, y, z)[source]¶ Bases:
object
Makes a mesh node.
Parameters: - node_num (int) – node number
- x (float) – x-coordinate
- y (float) – y-coordinate
- z (float) – z-coordinate
-
id
¶ node number
Type: int
-
x
¶ x-coordinate
Type: float
-
y
¶ y-coordinate
Type: float
-
z
¶ z-coordinate
Type: float
-
order
¶ 1 or 2, 1 if it is a corner node, 2 if it is a midside node
Type: int
-
elements
¶ a set of elements that contain this node
Type: set
-
faces
¶ a set of faces that contain this node
Type: set
-
add_element
(element)[source]¶ Adds an element to this node’s set of elements.
Parameters: element (Element) – element to add to set self.elements
pycalculix.partmodule module¶
This module stores the Part class. It is used to make 2D parts.
-
class
pycalculix.partmodule.
Part
(feamodel)[source]¶ Bases:
pycalculix.base_classes.Idobj
This makes a part.
Parameters: parent – parent FeaModel -
points
¶ list or part points, excludes arc centers
Type: list
-
allpoints
¶ list or part points, includes arc centers
Type: list
-
lines
¶ list of all Line and Arc that make the part
Type: list
-
signlines
¶ list of all SignLine and SignArc that make the part
Type: list
-
__holemode
¶ if True, lines will be added to holes, otherwise, they’ll be added to areas
Type: bool
-
areas
¶ list of Area that make up the part
Type: list
-
left
¶ list the parts leftmost lines, they must be vertical
Type: list
-
right
¶ list the parts rightmost lines, they must be vertical
Type: list
-
top
¶ list the parts top lines, they must be horizontal
Type: list
-
bottom
¶ list the parts bottom lines, they must be horizontal
Type: list
-
nodes
¶ list of part’s nodes
Type: list
-
elements
¶ list of part’s elements
Type: list
-
allpoints
Returns list of part points, includes arc centers.
-
chunk
(mode='both', exclude_convex=True, debug=[0, 0])[source]¶ Chunks all areas in the part.
Parameters: - mode (str) –
area chunking mode
- ’both’: cuts areas using holes and exterior points
- ’holes’: cut areas using holes points only
- ’ext’: cut areas using exterior points only
- exclude_convex (bool) – If true exclude cutting convex tangent points
- mode (str) –
-
draw_arc
(end_x, end_y, center_x, center_y)[source]¶ Makes an arc and adds it to the part.
Current point is the first arc point.(end_x, end_y) is the end point(center_x, center_y) is the arc centerDegrees: Traversed angle of arc must be < 180 degreesRadians: Traversed angle of arc must be < PiParameters: - end_x (float) – arc end point x-coordinate
- end_y (float) – arc end point y-coordinate
- center_x (float) – arc center point x-coordinate
- center_y (float) – arc center point y-coordinate
Returns: [arc, arc_start_point, arc_end_point]
Return type: list
-
draw_arc_angle
(degrees_ccw, center_x, center_y)[source]¶ Makes an arc and adds it to the part.
Current point is the first arc point.degrees_ccw is the swept angle in degrees, counterclockwise(center_x, center_y) is the arc centerDegrees: Traversed angle of arc must be < 180 degreesParameters: - degrees_ccw (float) – arc swept angle in degrees, counterclockwise
- center_x (float) – arc center point x-coordinate
- center_y (float) – arc center point y-coordinate
Returns: [arc, arc_start_point, arc_end_point]
Return type: list
-
draw_circle
(center_x, center_y, radius, num_arcs=4)[source]¶ Draws a circle area and adds it to the part.
Parameters: - center_x (float) – x-axis hole center
- center_y (float) – y-axis hole center
- radius (float) – hole radius
- num_arcs (int) – number of arcs to use, must be >= 3
Returns: a LineLoop list of SignArc
Return type: loop (geometry.LineLoop)
-
draw_hole
(center_x, center_y, radius, num_arcs=4, filled=False)[source]¶ Makes a hole in the part.
Parameters: - center_x (float) – x-axis hole center
- center_y (float) – y-axis hole center
- radius (float) – hole radius
- num_arcs (int) – number of arcs to use, must be >= 3
- filled (bool) –
whether to fill the hole
- True: makes a new area in the part
Returns: list of hole SignLine or SignArc
- Returns None if hole was not made.
Return type: hole_lines (list or None)
-
draw_line_ax
(dy_ax)[source]¶ Draws a line a relative axial distance, and adds it to the part.
Parameters: dy_ax (float) – y-axis delta distance to draw the line Returns: [line, point_start, point_end] Return type: list
-
draw_line_delta
(delta_x, delta_y)[source]¶ Draws a line a relative distance, and adds it to the part.
Parameters: - delta_x (float) – x-axis delta distance to draw the line
- delta_y (float) – y-axis delta distance to draw the line
Returns: [line, point_start, point_end]
Return type: list
-
draw_line_rad
(dx_rad)[source]¶ Draws a line a relative radial distance, and adds it to the part.
Parameters: dx_rad (float) – x-axis delta distance to draw the line Returns: [line, point_start, point_end] Return type: list
-
draw_line_to
(x, y)[source]¶ Draws a line to the given location, and adds it to the part.
Parameters: - x (float) – x-axis coordinate of the end point
- y (float) – y-axis coordinate of the end point
Returns: [SignLine, point_start, point_end]
Return type: list
-
fillet_all
(radius)[source]¶ Fillets all external lines not within 10 degrees of tangency
Parameters: radius (float) – the fillet radius to use Returns: list of SignArc Return type: arcs (list)
-
fillet_lines
(line1, line2, radius)[source]¶ Fillets the given lines in the part.
This inserts an arc in the part tangent to the two given lines.
Parameters: Returns: [arc, start_point, end_point]
Return type: list
-
get_item
(item)[source]¶ “Returns the part’s item(s) requested by the passed string.
Parameters: item (str) – string requesting item(s)
- Valid examples: ‘P0’, ‘L0’, ‘left’, ‘A0’
Returns: If items are found they are returned - If there is only one item it is returned
- If there are multiple items, they are returned as a list
- If no items are found None is returned
Return type: item(s) or None
-
goto
(x, y, holemode=False)[source]¶ Moves the part cursor to a location.
If that location has a point at it, use it. If not, make a new point at that location.
Parameters: - x (float) – x-coordinate of the point to go to
- y (float) – y-coordinate of the point to go to
- holemode (bool) – if True, we start drawing a hole here, otherwise we start drawing an area
Returns: returns the updated cursor point
Return type: self.__cursor (Point)
-
label
(axis)[source]¶ Labels the part on a Matplotlib axis
Parameters: axis (Matplotlib Axis) – Matplotlib Axis
-
lines
Returns list of part lines.
-
plot
(axis, label=True, color='yellow')[source]¶ Plots the part on the passed Matplotlib axis.
Parameters: - axis (Matplotlib axis) – the axis we will plot on
- label (bool) – True displays the part label
- color (tuple) – r,g,b,a matplotlib color tuple
-
points
Returns list of part points, excludes arc centers.
-
signlines
Returns list of part signline and signarc.
-
pycalculix.problem module¶
This module stores the Problem class which is used to solve different types of analysis.
-
class
pycalculix.problem.
Problem
(feamodel, problem_type, fname='')[source]¶ Bases:
pycalculix.base_classes.Idobj
Makes a problem which can be analyzed with Calculix ccx.
Parameters: - feamodel (-) – the parent FeaModel
- problem_type (-) – model type, options: – ‘struct’: structural
- fname (-) – file prefix for the problem .inp and results files If value is ‘’ it will default to the project name of the FeaModel
-
__ptype
¶ problem type, options:
- ‘struct’: structural
Type: str
-
solved
¶ boolean storing whether or not the analysis was solved
Type: bool
-
fname
¶ the problem database and results file prefix
Type: str
-
rfile
¶ Results_File is loaded in after the model has been solved
Type: Results_File
pycalculix.results_file module¶
This module stores the Results_File class.
-
class
pycalculix.results_file.
ResultsFile
(problem)[source]¶ Bases:
object
Makes a results file.
Parameters: problem (Problem) – problem that was solved -
__steps
¶ a list of float time steps
Type: list
-
__results
¶ a dict storing the results data results[step][‘node’][nnum][field] –> value results[step][‘element’][enum][‘avg’][field] –> value results[step][‘element’][enum][‘max’][field] –> value results[step][‘element’][enum][‘min’][field] –> value results[step][‘element’][enum][‘ipoints’][ipnum][field] –> value field = ‘ux’ or ‘Seqv’ or ‘ey’ etc.
Type: dict
-
__time
¶ current time we are looking at, defaults to -1 When a file is loaded in, the first time step is loaded.
Type: float
-
eplot
(field, fname='', display=True, levels=21, gmult=1.0, mode='avg', max_val=None, min_val=None, title='')[source]¶ Plots element results.
Parameters: - field (str) – results item to plot. Only stresses supported. Examples: ‘Sx’, ‘Sxy’, ‘S1’, ‘Seqv’ etc.
- fname (str) – prefix of png file name, if writing an image
- display (bool) – True = interactively show the plot
- levels (int) – number of levels to use in the colorbar
- gmult (int) – geometric multiplier on displacement of nodes displayed_node_loc = model_node_loc + gmult*node_displacement
- mode (str) –
the type of element result to plot
- ’avg’: integration points averaged to avg element result
- ’max’: max value of field in the integration points plotted
- ’min’: min value of field in the integration points plotted
- max_val (float or None) –
max value in the colorbar
- None: max from selected data used
- float: use the passed float
- min_val (float) –
min value in the colorbar
- None: min from selected data used
- float: use the passed float
- title (str) – third line in the plot title
-
get_emax
(field, time=None, mode='avg')[source]¶ Returns the max results field value of selected elements at curent time.
Parameters: - field (str) – results field, stresses supported ‘S1’, ‘Sx’, etc.
- time (None or float) –
the time to query
- None: uses the current time
- float: uses the passed float time
- mode (str) –
type of element result to give back
- ’max’: for each element only use the max value of field over
- all of its integration points
- ’min’: for each element only use the min value of field over
- all of its integration points
- ’avg’: for each element only use an average of all integration
- points in the eleemnt. Principal streses and Seqv are calculated after averaging 6 stress components.
Returns: max value
Return type: res (float)
-
get_emin
(field, time=None, mode='avg')[source]¶ Returns the min results field value of selected elements at curent time.
Parameters: - field (str) – results field, stresses supported ‘S1’, ‘Sx’, etc.
- time (None or float) –
the time to query
- None: uses the current time
- float: uses the passed float time
- mode (str) –
type of element result to give back
- ’max’: for each element only use the max value of field over
- all of its integration points
- ’min’: for each element only use the min value of field over
- all of its integration points
- ’avg’: for each element only use an average of all integration
- points in the eleemnt. Principal streses and Seqv are calculated after averaging 6 stress components.
Returns: min value
Return type: res (float)
-
get_eval
(element, field, time=None, mode='avg')[source]¶ Returns the field result value under element.
Result will be returned whether or not passed element is selected.
Parameters: - element (str or Element) – element we are asking about
- field (str) – the results item we want: ‘Sy’, ‘Seqv’
- mode (str) –
the type of element result to get
- ’avg’: integration points averaged to avg element result
- ’max’: max value of field in the integration points plotted
- ’min’: min value of field in the integration points plotted
Returns: float value if field exists, None otherwise
Return type: res (float or None)
-
get_fsum
(item)[source]¶ Returns the force sum on nodes under a given point or line.
Reports results for the current time.
Parameters: item (Point or SignLine) – item that has reaction forces on its nodes Returns: [fx, fy, fz] reaction forces in each axis, force units Return type: list
-
get_nmax
(field, time=None)[source]¶ Returns the max value of node results field in selected nodes.
Reports results for the current time.
Parameters: - field (str) – results field, for example ‘ux’, ‘ey’, ‘S1’, ‘Seqv’
- time (None or float) –
the time to query
- None: uses the current time
- float: uses the passed float time
Returns: max value
Return type: res (float)
-
get_nmin
(field, time=None)[source]¶ Returns the min value of node results field in selected nodes.
Reports results for the current time.
Parameters: - field (str) – results field, for example ‘ux’, ‘ey’, ‘S1’, ‘Seqv’
- time (None or float) –
the time to query
- None: uses the current time
- float: uses the passed float time
Returns: min value
Return type: res (float)
-
get_nval
(node, field, time=None)[source]¶ Returns the field result value under node.
Result will be returned whether or not passed node is selected.
Parameters: - node (str or Node) – node we are asking about
- field (str) – the results item we want: ‘ux’, ‘Sy’, ‘Seqv’, ‘fx’
- time (None or float) –
the time to query
- None: uses the current time
- float: uses the passed float time
Returns: float value if field exists, None otherwise
Return type: res (float or None)
-
get_relative_gradient
(start_point, end_point, field, n_poly=3, n_subpoints=500)[source]¶ Calculte relative stress gradient (gradient/start_value)
Parameters: - [ (end_point) – starting point of line. [x, y]
- [ – end point of line. Example: [x, y]
- field (str) – results item to plot, examples: ‘ux’, ‘ey’, ‘Seqv’
- Kargs:
- n_poly (int): numbers of polygons for fitting, min=2 n_subpoints (int): numbers of points the line is subdivided into
-
nplot
(field, fname='', display=True, levels=21, gradient=False, gmult=1.0, max_val=None, min_val=None, title='')[source]¶ Plots nodal results.
Parameters: - field (str) – results item to plot, examples: ‘ux’, ‘ey’, ‘Seqv’
- fname (str) – prefix of png file name, if writing an image
- display (bool) – True = interactively show the plot
- levels (int) – number of levels to use in the colorbar
- gradient (bool) – True = results plotted with gradient False = results plotted with filled areas
- gmult (int) – geometric multiplier on displacement of nodes displayed_node_loc = model_node_loc + gmult*node_displacement
- max_val (float or None) –
max value in the colorbar
- None: max from selected data used
- float: use the passed float
- min_val (float) –
min value in the colorbar
- None: min from selected data used
- float: use the passed float
- title (str) – third line in the plot title
-
plot_gradient
(start_point, end_point, field, fname='', display=True, title='', max_val=None, min_val=None, curve_fitting=True, n_poly=3, n_subpoints=500, legend=True)[source]¶ Create diagram with data projected onto line on the undeformed geometry.
Parameters: - [float, float] (end_point) – starting point of line. [x, y]
- [float, float] – end point of line. Example: [x, y]
- field (str) – results item to plot, examples: ‘ux’, ‘ey’, ‘Seqv’
- fname (str) – prefix of png file name, if writing an image
- display (bool) – True = interactively show the plot
- title (str) – third line in the plot title
- max_val (float or None) – max value in the y-axis - None: max from selected data used - float: use the passed float
- min_val (float or None) – min value in the y-axis - None: min from selected data used - float: use the passed float
- curve_fitting (bool) – True = a curve is fitted to the gradient
- n_poly (int) – numbers of polygons for fitting
- n_subpoints (int) – numbers of points the line is subdivided into
- legend (bool) – True = legend with fitted equation is shown
-
set_time
(time)[source]¶ Sets the time point we’re looking at in the results file.
Parameters: time (float) – time we are setting
-
steps
¶ Returns a list of loaded time steps.
Note: this is read only, you can not assign a value to it.
-
time
¶ Returns the current time (float) in the results file.
Note: this is read only, you can not assign a value to it.
-
pycalculix.selector module¶
This module stores the Selector object
Selector is used in FeaModel to store the model’s selected set.
-
class
pycalculix.selector.
Selector
(feamodel)[source]¶ Bases:
object
Makes a selector which stores the selected items in the FeaModel.
Parameters: feamodel (FeaModel) – the parent FeaModel object -
__all
¶ If everything is selected all=True
Type: bool
-
parts
¶ currently selected parts
Type: set
-
areas
¶ currently selected areas
Type: set
-
lines
¶ currently selected signed lines or arcs
Type: set
-
points
¶ currently selected points
Type: set
-
elements
¶ currently selected elements
Type: set
-
faces
¶ currently selected faces
Type: set
-
nodes
¶ currently selected nodes
Type: set
-
__parts
¶ internal storage set of parts
Type: set
-
__areas
¶ internal storage set of areas
Type: set
-
__slines
¶ internal storage set of signed lines and arcs
Type: set
-
__points
¶ internal storage set of points
Type: set
-
__elements
¶ internal storage set of elements
Type: set
-
__faces
¶ internal storage set of faces
Type: set
-
__nodes
¶ internal storage set of nodes
Type: set
-
allsel_under
(sel_type, full=True, byfaces=False)[source]¶ Selects all progeny under current sel_type items.
Parameters: - sel_type (str) –
the item type to select under
- ’parts’
- ’areas’
- ’lines’
- ’points’ (needs full=True)
- ’elements’
- ’faces’
- full (bool) –
if False selects under one branch
- solid modeling branch: area->line->keypoints->points
- mesh branch: elements->faces->nodes
Cross branch connections: - faces are under lines - elements are under areas - nodes are under lines and points
If True, selects all items connected to sub items: - Parts:
- Areas
- Elements, element faces + element nodes
- Lines, line points
- Areas:
- Elements, element faces + element nodes
- Lines, line points
-Lines:
- Faces, nodes
- byfaces=True: elements above faces
- byfaces=False: elements above line nodes selected
-Points:
- Nodes
- byfaces=True: no elements selected
- byfaces=False: elements above point nodes selected
- byfaces (bool) –
If true, the child elements will only be selected if a parent face was selected. If false just an element node needs to be selected to select the element.
-This is only applicable when sel_type == ‘lines’
- sel_type (str) –
-
areas
Returns selected areas.
-
deselect_all
(sel_type)[source]¶ Deselects all items of sel_type.
All items currently selected items are removed from the selection set before the all set is selected.
Parameters: sel_type (str) – the items to select
- ’all’
- ’parts’
- ’areas’
- ’lines’
- ’points’
- ’elements’
- ’faces’
- ’nodes’
-
elements
Returns selected elements.
-
faces
Returns selected faces.
-
lines
Returns selected signed lines or arcs.
-
nodes
Returns selected nodes.
-
parts
Returns selected parts.
-
points
Returns selected points.
-
select
(items='', also=False)[source]¶ Selects an item or a list of items.
- Agrs:
items (str or item or list): item(s) to select also (bool): whether to add the items to the current selection set
- True: add the items to the current selection set
- False: only select the passed items
-
select_above
(inclusive=False)[source]¶ Selects parents above currently selected items.
Only one set must be selected.
-
select_above_all
(sel_type, inclusive=False)[source]¶ Selects parents above all currently selected items of sel_type.
Parameters: - sel_type (str) –
type to select items above
- ’areas’: selects parts
- ’lines’: selects areas
- ’points’: selects signlines or signarcs
- ’faces’: selects elements
- ’nodes’: selects faces
- inclusive (bool) –
if True, all child entities must be selected for the parent to be selected. If false all parents connected to the child are selected. Exampes:
- ’areas’ + True: all part areas must be selected to select part
- ’areas’ + False: parts with selected areas in them are selected
- ’lines’ + True: all lines must be selected to select area
- ’lines’ + False: areas with selected lines in them are selected
- sel_type (str) –
-
select_all
(sel_type='all', also=False)[source]¶ Selects all items of sel_type from the full feamodel.
All items currently selected items are removed from the selection set before the all set is selected.
Parameters: - sel_type (str) –
the items to select
- ’all’
- ’parts’
- ’areas’
- ’lines’
- ’points’
- ’elements’
- ’faces’
- ’nodes’
- also (bool) – if False, empties the selection set before selecting all items, if True adds new items to the current set
- sel_type (str) –
-
select_below
()[source]¶ Selects children below currently selected items.
Only one set must be selected.
-
select_below_all
(sel_type)[source]¶ Selects children below all currently selected items of sel_type.
Parameters: sel_type (str) – type to select items below
- ’parts’: selects areas
- ’areas’: selects lines (type SignLine and SignArc)
- ’lines’: selects points
- ’elements’: selects faces
- ’faces’: selects nodes
-
pycalculix.version module¶
Module contents¶
pycalculix Description: This module provides a python interface to the Calculix FEA preprocessor and solver. Simplicity is emphasized.
2D models are supported including: plane stress, plane strain, and axisymmetric problems
Library Capabilities: Build Geometry Mesh Geometry Apply Loads Solve Model View Results Query Results Select Sub-Portion of Model and view those results
See documentation and examples at: http://justinablack.com/pycalculix/ https://github.com/spacether/pycalculix