Esempio n. 1
0
    def test_part_sides_skewed(self):
        # top right point in range, bottom right point out of range
        # left side perfet (2 found)
        # top in range but skewed on 2nd line (2 found)
        # right in range but skewed on 1st line, 2nd out of range (1 found)
        # bottom 1st out of range, in range but skewed on 2nd line, 2 (1 found)
        initial_accuracy_val = pyc.geometry.ACC
        pyc.geometry.ACC = 0.2
        offset_in_range = 0.1
        offset_too_big = 0.4

        proj_name = 'test_part_sides_skewed'

        model = pyc.FeaModel(proj_name)
        model.set_units('m')  # this sets dist units to meters
        part = pyc.Part(model)

        divot_width = 1
        corner_width = 2

        part.goto(0, 0)
        left_points = [
            (corner_width, 0),
            (corner_width + divot_width, divot_width),
            (corner_width + divot_width * 2, 0),
            (corner_width * 2 + divot_width * 2, 0),
        ]
        top_points = [
            (corner_width * 2 + divot_width * 2, corner_width),
            (corner_width * 2 + divot_width, corner_width + divot_width),
            (corner_width * 2 + divot_width * 2,
             corner_width + divot_width * 2),
            (corner_width * 2 + divot_width * 2 - offset_in_range,
             corner_width * 2 + divot_width * 2 - offset_in_range),
        ]
        right_points = [
            (corner_width + divot_width * 2,
             corner_width * 2 + divot_width * 2),
            (corner_width + divot_width, corner_width * 2 + divot_width),
            (corner_width, corner_width * 2 + divot_width * 2),
            (0 + offset_too_big,
             corner_width * 2 + divot_width * 2 - offset_too_big),
        ]
        bottom_points = [
            (0, corner_width + divot_width * 2),
            (divot_width, corner_width + divot_width),
            (0, corner_width),
            (0, 0),
        ]
        all_points = left_points + top_points + right_points + bottom_points
        for x, y in all_points:
            part.draw_line_to(x, y)

        self.assertEqual([line.get_name() for line in part.left], ['L0', 'L3'])
        self.assertEqual([line.get_name() for line in part.top], ['L4', 'L7'])
        self.assertEqual([line.get_name() for line in part.right], ['L8'])
        self.assertEqual([line.get_name() for line in part.bottom], ['L15'])
        pyc.geometry.ACC = initial_accuracy_val
Esempio n. 2
0
    def test_part_sides_perfect(self):
        # a hole with multiple lines for each side sets them correctly
        proj_name = 'test_part_sides'

        model = pyc.FeaModel(proj_name)
        model.set_units('m')  # this sets dist units to meters
        part = pyc.Part(model)

        divot_width = 1
        corner_width = 2

        part.goto(0, 0)
        left_points = [
            (corner_width, 0),
            (corner_width + divot_width, divot_width),
            (corner_width + divot_width * 2, 0),
            (corner_width * 2 + divot_width * 2, 0),
        ]
        top_points = [
            (corner_width * 2 + divot_width * 2, corner_width),
            (corner_width * 2 + divot_width, corner_width + divot_width),
            (corner_width * 2 + divot_width * 2,
             corner_width + divot_width * 2),
            (corner_width * 2 + divot_width * 2,
             corner_width * 2 + divot_width * 2),
        ]
        right_points = [
            (corner_width + divot_width * 2,
             corner_width * 2 + divot_width * 2),
            (corner_width + divot_width, corner_width * 2 + divot_width),
            (corner_width, corner_width * 2 + divot_width * 2),
            (0, corner_width * 2 + divot_width * 2),
        ]
        bottom_points = [
            (0, corner_width + divot_width * 2),
            (divot_width, corner_width + divot_width),
            (0, corner_width),
            (0, 0),
        ]
        all_points = left_points + top_points + right_points + bottom_points
        for x, y in all_points:
            part.draw_line_to(x, y)

        self.assertEqual([line.get_name() for line in part.left], ['L0', 'L3'])
        self.assertEqual([line.get_name() for line in part.top], ['L4', 'L7'])
        self.assertEqual([line.get_name() for line in part.right],
                         ['L8', 'L11'])
        self.assertEqual([line.get_name() for line in part.bottom],
                         ['L12', 'L15'])
Esempio n. 3
0
    def test_quad_mesh(self, el_shape='quad'):
        proj_name = 'sample'
        length = 4.0  # hole diam

        model = pyc.FeaModel(proj_name)
        model.set_units('m')  # this sets dist units to meters
        part = pyc.Part(model)

        part.goto(0, 0)
        part.draw_line_ax(length)
        part.draw_line_rad(length)
        part.draw_line_ax(-length)
        part.draw_line_rad(-length)

        # set the element type and mesh database
        model.set_eshape(el_shape, 2)
        model.mesh(1.0, 'gmsh')  # mesh 1.0 fineness, smaller is finer
        # model.plot_elements(proj_name+'_elem')   # plot part elements
        self.assertTrue(self.most_are_type(part.elements, el_shape))
#!/usr/bin/env python3
import sys

import pycalculix as pyc

# Vertical hole in plate model, make model
proj_name = 'hole-in-plate-full'
model = pyc.FeaModel(proj_name)
model.set_units('m')  # this sets dist units to meters

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

# Define variables we'll use to draw part geometry
diam = 2.0  # hole diam
ratio = 0.45
width = diam / ratio  # plate width
print('D=%f, H=%f, D/H=%f' % (diam, width, diam / width))
length = 2 * width  # plate length

# Draw part geometry, you must draw the part CLOCKWISE,
# x, y = radial, axial
part = pyc.Part(model)
part.goto(length * 0.5, -width * 0.5)
part.draw_line_ax(width)
Esempio n. 5
0
#!/usr/bin/env python3
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)
# this sets dist units to meters, labels our consistent units
model.set_units('m')

# set whether or not to show gui plots
show_gui = False
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
dens_water = 1000  # kg/m^3
press_atm = 101325  # Pascals = N/m^2 = kg/(m-s^2)
dam_ht_ft = 115
water_ht_ft = 109
length_dam_ft = 580
Esempio n. 6
0
 def example_load_results(self, file_name):
     proj_name = os.path.join('examples', file_name)
     model = pyc.FeaModel(proj_name)
     prob = pyc.Problem(model, 'struct')
     prob.rfile.load()