Getting Started

A simple example of running a structural simulation. Any geometry files used in these examples are available in the examples/ folder.

Utilities

pyintact has utility functions related to logging.

# First setup logging to log INFO level messages
setupLogging(0)
# Log INFO level messages to a log file in the current directory
addLogFile("log.txt", 0)

Import Intact Module

from pyintact import *

Create Geometry

beam_geometry = MeshModel("beam.stl")
beam_geometry.instance_id = "simple_cantilever"
beam_geometry.refine(0.02) # refine stl for smoother visualization

Create Material

Properties are in MKS unit system.

material = IsotropicMaterialDescriptor() # steel
material.density = 7800.0 # kg/m^3
material.poisson_ratio = 0.3
material.youngs_modulus = 2.1e11 # Pa

Create Restraints and Loads

# Create a fixed boundary condition at one end of the beam
fixed_boundary = FixedBoundaryDescriptor()
fixed_boundary.boundary = MeshModel("restraint.stl")

# Create a pressure load at the free end of the beam
pressure_load = PressureForceDescriptor()
pressure_load.units = UnitSystem.MeterKilogramSecond
pressure_load.magnitude = 1000  # Applying pressure in Pascals
pressure_load.boundary = MeshModel("load.stl")

Setup Simulation and Solve

# Setup the simulation scenario descriptor
scenario = LinearElasticScenarioDescriptor()
scenario.materials = {"Steel": material}
scenario.metadata.resolution = 10000
scenario.metadata.units = UnitSystem.MeterKilogramSecond
scenario.boundary_conditions = [fixed_boundary, pressure_load]

# Associate the material with the model
component = MaterialDomain(beam_geometry, "Steel", scenario)
assembly = [component]

# Initialize and run the simulator
simulator = StressSimulator(assembly, scenario)
simulator.solve()

Query Results and Visualize

# Query results for stress distribution
results = QueryResult(assembly)
stress_query = FieldQuery(Field.VonMisesStress)
simulator.sample(stress_query, results)

# Write results to a file (unit system is saved as a metadata in the vtu file)
results.writeVTK("cantilever_beam_results.vtu", UnitSystem.MeterKilogramSecond)