### Install abqpy using pip
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
Installs the abqpy package using pip. It supports installing specific versions and the Jupyter integration. Ensure Python 3.7+ and Abaqus 2016+ are installed.
```shell
pip install -U abqpy==2024.*
```
```shell
pip install -U abqpy2024
```
```shell
pip install git+https://github.com/haiiliin/abqpy@2024
```
```shell
pip install -U abqpy[jupyter]==2024.*
pip install -U abqpy2024[jupyter]
pip install ipynbname nbconvert
```
--------------------------------
### Execute Abaqus Script using abqpy CLI
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
The abqpy command provides a convenient way to run Abaqus scripts, allowing for customization of the Python launch command. This is an alternative to using the 'abaqus' command directly.
```sh
[python -m] abqpy cae script.py
```
--------------------------------
### Execute Abaqus Python scripts
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
Demonstrates how to execute Python scripts with Abaqus using the command line. This allows for running Abaqus models, jobs, and output extraction directly from a script without opening the Abaqus/CAE GUI.
```shell
abaqus cae \
[database=database-file] \
[replay=replay-file] \
[recover=journal-file] \
[startup=startup-file] \
[script=script-file] \
[noGUI=noGUI-file] \
[noenvstartup] \
[noSavedOptions] \
[noSavedGuiPrefs] \
[noStartupDialog] \
[custom=script-file] \
[guiTester=GUI-script] \
[guiRecord] \
[guiNoRecord]
```
--------------------------------
### Fetch Abaqus Example Data
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/cantilever.md
This command retrieves the necessary output database for the 'beamExample' job, which is then read by the analysis scripts. Ensure you have Abaqus installed and configured in your environment to run this command.
```shell
abaqus fetch job=beamExample
```
--------------------------------
### Run Abaqus Script with abaqus python
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
This command executes a Python script using the Abaqus Python interpreter. It's typically used when the script only requires the Abaqus Python interpreter and not the full Abaqus/CAE kernel.
```sh
abaqus python script.py
```
--------------------------------
### Embed Utterances Comments with JavaScript
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
This snippet embeds the Utterances comments system using a script tag. It requires specifying the GitHub repository, issue term strategy, and theme. The script is loaded asynchronously.
```html
```
--------------------------------
### Run Abaqus Script Directly with Python 3
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
This method uses the standard Python 3 interpreter to run the Abaqus script. It is equivalent to using the 'abqpy' command with default predefined arguments, offering a convenient execution flow.
```sh
python script.py
```
--------------------------------
### Run Abaqus Script with abaqus cae noGUI
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
This command executes an Abaqus script using the Abaqus CAE environment without opening the graphical user interface. It's a common method for batch processing Abaqus jobs.
```sh
abaqus cae noGUI=script.py
```
--------------------------------
### Install abqpy Documentation Dependencies
Source: https://github.com/zy111x/abqpy/blob/2024/docs/README.md
Installs the necessary Python dependencies for building the abqpy documentation. This command should be run from the root directory of the repository.
```bash
pip install .[docs]
```
--------------------------------
### Fetch Abaqus Example Scripts
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/index.md
Demonstrates how to use the Abaqus fetch utility to retrieve example scripts from the documentation. This is a command-line utility, and the input is the job name of the desired script.
```shell
abaqus fetch job=scriptName
```
--------------------------------
### Fetch Example Script and Output Database
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
These commands are used to download the `odbMaxMises.py` script and the `viewer_tutorial` output database, which are necessary to run the example.
```python
# abaqus fetch job=odbMaxMises.py
# abaqus fetch job=viewer_tutorial
```
--------------------------------
### Fetch Abaqus Example Script
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/about/examples/create-part.md
This command-line utility allows users to retrieve example scripts for Abaqus. It takes the job name as an argument, which corresponds to the script file name (e.g., scriptName.py). This is useful for accessing and running provided examples.
```sh
abaqus fetch job=scriptName
```
```sh
abaqus fetch job=modelAExample
```
--------------------------------
### Execute Abaqus Script using abqpy.cli.abaqus object
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/getting_started.md
This Python code snippet demonstrates how to use the `abqpy.cli.abaqus` object to programmatically run Abaqus scripts. It's useful for invoking Abaqus scripts from within other Python scripts, benefiting from type annotations and docstrings.
```python
from abqpy.cli import abaqus
abaqus.cae(script="script.py")
```
--------------------------------
### Build abqpy HTML Documentation
Source: https://github.com/zy111x/abqpy/blob/2024/docs/README.md
Builds the HTML version of the abqpy documentation. After installing dependencies, navigate to the 'docs' directory and run this command. The output will be in the 'build/html' directory.
```bash
cd docs
make html
```
--------------------------------
### Fetch Abaqus Example Files via Shell Command
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/about/examples/read-output.md
These shell commands are used to download necessary files for the Abaqus scripting example. `abaqus fetch job=odbExample` retrieves the Python script, and `abaqus fetch job=viewer_tutorial` retrieves the output database file (`.odb`) that the script will process.
```shell
abaqus fetch job=odbExample
```
```shell
abaqus fetch job=viewer_tutorial
```
--------------------------------
### Starting Abaqus PDE from Command Line
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/environment/pde-basics.md
This snippet shows how to launch the Abaqus PDE from a system command prompt. It can be initiated alongside Abaqus/CAE for integrated scripting or started independently. The command allows specifying script files to open at startup and accepts Abaqus/CAE command-line arguments for advanced configurations.
```shell
abaqus cae -pde
```
```shell
abaqus pde [filenames] [-script filename] [-pde Abaqus/CAE command line arguments]
```
--------------------------------
### Fetch Example Script for Field Operations
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This shell command fetches an example script and input file for demonstrating field operation computations in Abqpy. The fetched script can be used to generate an output database for further analysis.
```shell
abaqus fetch job=fieldOperation
```
--------------------------------
### Fetch Example Script for Displacement Magnitude History
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This shell command fetches an example script and input file for computing displacement magnitude history from components using Abqpy. The fetched files can be used to generate the output database required by the script.
```shell
abaqus fetch job=compDispMagHist
```
--------------------------------
### Fetch Abaqus odbDump Example Program
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/examples.md
This command retrieves the 'odbDump' example program, which demonstrates how to read and print the content of an Abaqus output database. The example covers various aspects of the output database structure.
```sh
abaqus fetch job=odbDump
```
--------------------------------
### Fetch abaqus ODB example source and tutorial data
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/examples.md
These commands retrieve the C++ source code for the `odbMaxMises` job and the 'viewer_tutorial' output database required to run the example.
```c++
// abaqus fetch job=odbMaxMises.C
// abaqus fetch job=viewer_tutorial
```
--------------------------------
### Detailed Structure of Abaqus Output Database (Pretty Print Example)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/output-object-model.md
Provides an example of the detailed, structured output generated by the `prettyPrint` function when applied to an Abaqus output database. It includes information about the analysis, job data, parts, assembly, steps, and user data.
```python
(
{
"analysisTitle": "Cantilever beam tutorial",
"closed": False,
"description": "DDB object",
"diagnosticData": (
{
"analysisErrors": "OdbSequenceAnalysisError object",
"analysisWarnings": "OdbSequenceAnalysisWarning object",
"jobStatus": JOB_STATUS_COMPLETED_SUCCESSFULLY,
"jobTime": "OdbJobTime object",
"numberOfAnalysisErrors": 0,
"numberOfAnalysisWarnings": 0,
"numberOfSteps": 1,
"numericalProblemSummary": "OdbNumericalProblemSummary object",
"steps": "OdbSequenceDiagnosticStep object",
}
),
"isReadOnly": False,
"jobData": (
{
"analysisCode": ABAQUS_STANDARD,
"creationTime": "date time year",
"machineName": "",
"modificationTime": "date time year",
"name": "Deform.odb",
"precision": SINGLE_PRECISION,
"productAddOns": "tuple object",
"version": "Abaqus/Standard release",
}
),
"name": "Deform.odb",
"parts": {"BEAM": "Part object"},
"path": "C:/Deform.odb",
"rootAssembly": (
{
"connectorOrientations": "ConnectorOrientationArray object",
"datumCsyses": "Repository object",
"elementSet": "Repository object",
"elementSets": "Repository object",
"elements": "OdbMeshElementArray object",
"instance": "Repository object",
"instances": "Repository object",
"name": "ASSEMBLY",
"nodeSet": "Repository object",
"nodeSets": "Repository object",
"nodes": "OdbMeshNodeArray object",
"sectionAssignments": "Sequence object",
"surface": "Repository object",
"surfaces": "Repository object",
}
),
"sectionCategories": {"solid < STEEL >": "SectionCategory object"},
"sectorDefinition": None,
"steps": {"Beamload": "OdbStep object"},
"userData": (
{
"annotations": "Repository object",
"xyData": "Repository object",
"xyDataObjects": "Repository object",
}
),
}
)
```
--------------------------------
### Abaqus: Viewport Constructor with Arguments
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/style.md
Demonstrates the syntax for calling a constructor that accepts arguments, using the Viewport constructor as an example with an ellipsis indicating arguments.
```python
Viewport(...)
```
--------------------------------
### Access and Print GUI Preferences in Abaqus
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/settings.md
This example shows how to import necessary functions from caePrefsAccess, retrieve the GUI preferences file name, get available display names, and then open and print the values for a specific display name's GUI preferences. This is useful for inspecting GUI layout and behavior settings.
```Python
import caePrefsAccess
from caePrefsAccess import openGuiPreferences, CURRENT, HOME
from caePrefsAccess import getGuiPrefsFileName, getDisplayNamesInGuiPreferences
from caePrefsAccess import printValuesList
guiPrefsFileName = getGuiPrefsFileName()
dispNames = getDisplayNamesInGuiPreferences(guiPrefsFileName)
print(dispNames)
displayName = dispNames[0]
guiPrefs = openGuiPreferences(displayName)
printValuesList(guiPrefs)
```
--------------------------------
### Python Function Call Example (pycon)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/programming.md
Illustrates calling a Python function named `distance` with specific arguments and displaying the returned result. This example uses the `pycon` interactive interpreter format to show the input and output.
```python
>>> distance(4.7, 9.1)
10.2420701033
```
--------------------------------
### Fetch Abaqus Example Program
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/examples.md
This command retrieves the example program for calculating stress range. It also fetches an associated input file necessary for generating an output database that the example program can read.
```shell
abaqus fetch job=stressRange
```
--------------------------------
### Fetch Abaqus Tutorial Database using abaqus fetch
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/read.md
This command-line utility retrieves example Abaqus output databases and related scripts for local use. It requires the job name as an argument.
```shell
abaqus fetch job=name
```
```shell
abaqus fetch job=viewer_tutorial
```
--------------------------------
### Fetch Abaqus Example Script: compositeBeam
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This command retrieves the example script named 'compositeBeam' for use with Abaqus. This script is essential for performing the meshed beam cross-section analysis and viewing its results.
```shell
abaqus fetch job=compositeBeam
```
--------------------------------
### C++ Odb Constructor and Variable Assignment
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/style.md
Demonstrates the usage of the Odb constructor, which returns an Odb object. The example shows how the returned object can be assigned to a variable for subsequent use.
```C++
odb_Odb newOdb& = Odb("new", "", "", fileName);
```
--------------------------------
### Starting Abaqus PDE with Custom Application Debugging
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/environment/use-pde.md
This command initiates the Abaqus PDE debugger along with a custom application, allowing for debugging of custom scripts that extend Abaqus/CAE functionality. The `-pde` flag starts the PDE, and `[args]` represent the necessary arguments for your custom application.
```sh
abaqus pde -pde [args]
```
--------------------------------
### Fetch Abaqus Tutorial Data using abaqus fetch
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/read.md
The `abaqus fetch` command is used to retrieve example scripts and output database files for Abaqus tutorials. This is useful for practicing with the Abaqus Scripting Interface and analyzing tutorial data.
```shell
abaqus fetch job=name
```
```shell
abaqus fetch job=viewer_tutorial
```
--------------------------------
### Fetch Example Script for Region Field Value Computations
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This shell command retrieves an example script and input file for computing sum and average stress field values within a region using Abqpy. The fetched files can be used to generate the necessary output database.
```shell
abaqus fetch job=sumRegionFieldValue
```
--------------------------------
### Python Integer Data Type Examples
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Illustrates the creation and manipulation of integer and long integer data types in Python. It includes examples of type conversion using `int()` and `long()` and printing results.
```python
>>> i = 20
>>> j = 64
```
```python
>>> nodes = 2000000L
>>> bigNumber = 120L**21
```
```python
>>> load = 279.86
>>> iLoad = int(load)
>>> iLoad
279
>>> a = 2
>>> b = 64
>>> bigNumber = long(a) ** b
>>> print("bigNumber = ", bigNumber)
bigNumber = 18446744073709551616
```
--------------------------------
### Access Steps from Output Database
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/about/examples/read-output.md
Retrieves specific steps from the output database. The example shows how to access 'Step-1' and 'Step-2' (though 'Step-2' is defined implicitly in the frame assignment).
```python
firstStep = myOdb.steps["Step-1"]
```
```python
secondStep = myOdb.steps["Step-2"]
```
--------------------------------
### Generate Integer Sequences with range() in Python
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Illustrates the use of the `range()` function to generate sequences of integers with specified start, end, and step values. Useful for loop control.
```python
print(list(range(2, 8)))
print(list(range(4)))
print(list(range(1, 8, 2)))
```
--------------------------------
### Abaqus: Creating a FieldOutput Object
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/style.md
Provides an example of how to create a FieldOutput object using the Abaqus Scripting Interface, specifying its name, description, and type.
```python
myFieldOutput = (
session.odbs[name]
.steps["Side load"]
.frames[-1]
.FieldOutput(name="S", description="stress", type=TENSOR_3D_FULL)
)
```
--------------------------------
### List Methods of a Viewport Object (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/oop.md
This example demonstrates how to list all available methods for a given Abaqus object, in this case, a Viewport. This is useful for understanding the object's capabilities and available actions. The `__methods__` attribute provides this information.
```python
session.viewports["myViewport"].__methods__
```
--------------------------------
### Abaqus: makeCurrent Method with No Arguments
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/style.md
Shows an example of calling a method that takes no arguments, using the `makeCurrent` method.
```python
makeCurrent()
```
--------------------------------
### Configure Abaqus/CAE Startup Preferences with Python
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/environment-file.md
This snippet configures graphics, print, job, and visualization preferences when Abaqus/CAE starts. It utilizes the `onCaeStartup` and `onCaeGraphicsStartup` functions, along with `addImportCallback` to hook into module imports for custom settings.
```python
scratch = "c:/temp"
memory = "256mb"
def onCaeGraphicsStartup():
# Graphics preferences
#
session.defaultGraphicsOptions.setValues(displayLists=OFF, dragMode=AS_IS)
def onCaeStartup():
# Print preferences
#
session.printOptions.setValues(
vpDecorations=OFF, vpBackground=OFF, rendition=COLOR, printCommand="lpr"
)
session.psOptions.setValues(date=OFF)
# Job preferences
#
def setJobPreferences(module, userData):
import job
session.Queue(
name="long", hostName="server", queueName="large", directory="/tmp"
)
addImportCallback("job", setJobPreferences)
# Visualization preferences
#
def setVisPreferences(module, userData):
import visualization
session.defaultOdbDisplay.contourOptions.setValues(
renderStyle=SHADED, visibleEdges=EXTERIOR, contourStyle=CONTINUOUS
)
addImportCallback("visualization", setVisPreferences)
```
--------------------------------
### Verify and Initialize Model Database Contents (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/extending.md
This Python example illustrates how to register custom application data, define version information, and then use `setAppData`, `setVerifyMdb`, and `setInitializeMdb` (implicitly via `processInitialMdb` in this context) to manage model database verification and initialization upon opening or creation.
```python
from abaqus import mdb, session
import customKernel
myAppName = "My App"
myAppData = customKernel.AbaqusAppData()
myAppData.majorVersion = 1
myAppData.minorVersion = 1
myAppData.updateVersion = 1
customKernel.setAppData(myAppName, myAppData)
```
--------------------------------
### C++ Repository Iteration with odb_StepRepository
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/utility.md
Provides an example of iterating through an Abaqus step repository using odb_StepRepository and its iterator. It demonstrates how to access keys (step names) and values (step objects) from the repository and print their details.
```c++
odb_StepRepository stepCon = odb.steps(); odb_StepRepositoryIT iter(stepCon); for (iter.first(); !iter.isDone(); iter.next()) {
cout << "step name : " << iter.currentKey().CStr() << endl;
const odb_Step& step = iter.currentValue();
cout << "step description : " << step.description().CStr();
cout << endl;
}
```
--------------------------------
### Import Abaqus Modules and Execute Startup Function
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Imports necessary Abaqus modules ('abaqus', 'abaqusConstants', 'driverUtils') and executes the 'executeOnCaeStartup' function. This is typically the header for Abaqus Python scripts.
```Python
from abaqus import *
from abaqusConstants import *
from driverUtils import *
executeOnCaeStartup()
```
--------------------------------
### Create Element and Node Sets on Abaqus Instances and Assembly
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/write.md
These examples show how to create element and node sets using element and node labels. Sets can be created on part instances or the root assembly. For the root assembly, instance names must be specified for nodes and elements.
```python
# An element set on an instance
eLabels = [9, 99]
elementSet = instance1.ElementSetFromElementLabels(name="elsetA", elementLabels=eLabels)
# A node set on the rootAssembly
nodeLabels = (5, 11)
instanceName = "part-1-1"
nodeSet = assembly.NodeSetFromNodeLabels(
name="nodesetRA", nodeLabels=((instanceName, nodeLabels),)
)
```
--------------------------------
### Create Viewport Object using Constructor (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/oop.md
This example shows how to create a new Viewport object using its constructor. Constructors in Abaqus typically start with an uppercase letter and are named after the object type they create. This requires specifying the name, width, and height for the new viewport.
```python
myViewport = session.Viewport(name="newViewport", width=100, height=100)
```
--------------------------------
### Interact with repositories using Python
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/extending.md
Illustrates the usage of repository methods to manage custom objects. This example creates a 'blocks' repository, adds two 'Block' objects, and then demonstrates querying repository keys, checking for key existence, renaming a key, and accessing object attributes.
```python
from customKernel import CommandRegister
class Block(CommandRegister):
def __init__(self, name):
CommandRegister.__init__(self)
mdb.customData.Repository("blocks", Block)
mdb.customData.Block(name="Block-1")
mdb.customData.Block(name="Block-2")
print("The original repository keys are: ", mdb.customData.blocks.keys())
print(mdb.customData.blocks.has_key("Block-2"))
print(mdb.customData.blocks.has_key("Block-3"))
mdb.customData.blocks.changeKey("Block-1", "Block-11")
print("The modified repository keys are: ", mdb.customData.blocks.keys())
print("The name member is ", mdb.customData.blocks["Block-11"].name)
print("The repository size is", len(mdb.customData.blocks))
```
--------------------------------
### Get User Inputs Without Default Values (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/user-input.md
This example demonstrates using the `getInputs` function when no default values are provided for the input fields. An empty string is used to indicate the absence of a default value. The function returns the user's input as strings.
```python
fields = (("Width", ""), ("Length", ""), ("Height", ""))
length, width, height = getInputs(fields=fields, label="Specify block dimensions:")
```
--------------------------------
### Define Element Types and Mesh Part in Abaqus using abqpy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Configures the mesh for a part in Abaqus by defining element types and seeding the part for meshing. This example includes linear and quadratic tetrahedral and hexahedral elements. It then seeds the part with a specified mesh size and generates the mesh.
```Python
elem1 = mesh.ElemType(elemCode=C3D8R)
elem2 = mesh.ElemType(elemCode=C3D6)
elem3 = mesh.ElemType(elemCode=C3D4)
part.setElementType(regions=(part.cells, ), elemTypes=(elem1, elem2, elem3))
part.seedPart(size=0.1)
part.generateMesh()
```
--------------------------------
### Create Abaqus Output Database with Model, Field, and History Data
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This Python script demonstrates how to use Abaqus Scripting Interface commands to create a new output database. It covers adding model data, field data, and history data, as well as reading and saving the output database. This is a foundational example for advanced output database manipulation.
```python
# Example script to retrieve and demonstrate output database creation
```
--------------------------------
### Install abqpy Package using Pip
Source: https://github.com/zy111x/abqpy/blob/2024/README.md
This command installs or updates the abqpy package to a specific major version compatible with your Abaqus installation. Ensure Python 3.7+ and Abaqus are installed prior to execution.
```bash
pip install -U abqpy==2024.* # change the major version to match your Abaqus version
```
--------------------------------
### Get Multiple User Inputs with Default Values (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/user-input.md
The `getInputs` function prompts the user for multiple text inputs via a dialog box. It accepts a list of field descriptions and default values. The function returns the user's input as strings. If the user cancels, it returns None values. This example shows how to define fields with default values for block dimensions.
```python
from abaqus import getInputs
fields = (("Width:", "10"), ("Length:", "20"), ("Height:", "30"))
length, width, height = getInputs(
fields=fields,
label="Specify block dimensions:",
dialogTitle="Create Block",
)
print(length, width, height)
```
--------------------------------
### Create and Submit Abaqus Job
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Creates an Abaqus job, writes the input file, submits the job for analysis, and waits for its completion. This initiates and manages the simulation.
```Python
job = mdb.Job(name='Job-1', model='Model-1')
job.writeInput()
job.submit()
job.waitForCompletion()
```
--------------------------------
### Python Dictionary Initialization and Element Access
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/programming.md
Demonstrates the creation of an empty dictionary and adding key-value pairs to it. It also shows how to access specific values using their keys and perform operations with these values.
```python
myPart = {}
myPart["size"] = 3.0
myPart["material"] = "Steel"
myPart["color"] = "Red"
myPart["number"] = 667
myPart["weight"] = 376.0
myPart["cost"] = 10.34
costOverWeight = myPart["cost"] / myPart["weight"]
description = myPart["color"] + myPart["material"]
```
--------------------------------
### Initialize Abaqus Session and Open ODB using abqpy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Initializes the Abaqus session and opens an output database (ODB) file. This is the first step in post-processing, allowing access to simulation results. It also sets the displayed object in the primary viewport to the opened ODB.
```Python
from abaqus import *
from abaqusConstants import *
from driverUtils import *
executeOnCaeStartup()
import visualization
odb = session.openOdb('Job-1.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
```
--------------------------------
### Create an Instance of a Part in Abaqus Assembly
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Shows how to create an instance of a previously defined part within the Abaqus root assembly. This step is fundamental for building complex assemblies from individual parts.
```Python
model.rootAssembly.Instance(name='instance', part=part, dependent=ON)
```
--------------------------------
### Example Usage of Material Object in Abaqus
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/style.md
Provides examples of how to interact with a Material object, including accessing its elastic properties and type. This illustrates the qualification of commands with 'mdb'.
```python
mdb.models[crash].Material[steel]
mdb.models[crash].materials[steel].Elastic(table=((30000000.0, 0.3),))
elasticityType = mdb.models[crash].materials[steel].elastic.type
```
--------------------------------
### Creating a Model Object in Abaqus
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/about/examples/summary.md
Demonstrates the creation of a model object using the Model constructor in the Abaqus Scripting Interface. This is a fundamental step for many scripting operations within Abaqus.
```python
myModel = mdb.Model(name="Model A")
```
--------------------------------
### Complete Abaqus Model Creation Script
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
This is the complete Python script for creating a 3D deformable part, defining sets, materials, sections, assembly, analysis steps, loads, boundary conditions, meshing, and job submission for a compression analysis in Abaqus.
```Python
from abaqus import *
from abaqusConstants import *
from caeModules import *
from driverUtils import *
executeOnCaeStartup()
# Model
model = mdb.models['Model-1']
# Part
sketch = model.ConstrainedSketch(name='sketch', sheetSize=1.0)
sketch.rectangle((0, 0), (1, 1))
part = model.Part(name='part', dimensionality=THREE_D, type=DEFORMABLE_BODY)
part.BaseSolidExtrude(sketch=sketch, depth=1)
# Create sets
part.Set(name='set-all', cells=part.cells.findAt(coordinates=((0.5, 0.5, 0.5), )))
part.Set(name='set-bottom', faces=part.faces.findAt(coordinates=((0.5, 0.5, 0.0), )))
part.Set(name='set-top', faces=part.faces.findAt(coordinates=((0.5, 0.5, 1.0), )))
part.Surface(name='surface-top',
side1Faces=part.faces.findAt(coordinates=((0.5, 0.5, 1.0), )))
# Assembly
model.rootAssembly.DatumCsysByDefault(CARTESIAN)
model.rootAssembly.Instance(name='instance', part=part, dependent=ON)
# Material
material = model.Material(name='material')
material.Elastic(table=((1000, 0.2), ))
material.Density(table=((2500, ), ))
# Section
model.HomogeneousSolidSection(name='section', material='material', thickness=None)
part.SectionAssignment(region=part.sets['set-all'], sectionName='section')
```
--------------------------------
### Fetch Abaqus Tutorial Output Database
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/plot.md
Retrieves the 'viewer_tutorial.odb' file, which is used in Abaqus Visualization module tutorials. This command is essential for running subsequent plotting scripts.
```sh
abaqus fetch job=viewer_tutorial
```
--------------------------------
### Define Sets and Surfaces for Abaqus Model
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Illustrates how to define sets and surfaces on a part using coordinates. This is crucial for applying boundary conditions and loads in Abaqus scripting, using 'findAt' method for cells and faces.
```Python
part.Set(name='set-all', cells=part.cells.findAt(coordinates=((0.5, 0.5, 0.5), )))
part.Set(name='set-bottom', faces=part.faces.findAt(coordinates=((0.5, 0.5, 0.0), )))
part.Set(name='set-top', faces=part.faces.findAt(coordinates=((0.5, 0.5, 1.0), )))
part.Surface(name='surface-top',
side1Faces=part.faces.findAt(coordinates=((0.5, 0.5, 1.0), )))
```
--------------------------------
### Create Static Analysis Step
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Defines a static analysis step with specified time period and incrementation controls. This sets up the simulation's time-dependent behavior.
```Python
step = model.StaticStep(name='Step-1', previous='Initial', description='',
timePeriod=1.0, timeIncrementationMethod=AUTOMATIC,
maxNumInc=100, initialInc=0.01, minInc=0.001, maxInc=0.1)
```
--------------------------------
### Execute Script on Abaqus CAE Startup
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/reference/index.md
Utilizes the `executeOnCaeStartup` function from the `driverUtils` module to ensure a specific Python script runs automatically every time the Abaqus/CAE environment is launched. This is useful for setting up a consistent environment or running initialization tasks.
```python
executeOnCaeStartup()
```
--------------------------------
### GeomSequence Example: Creating a Part
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/sequences.md
Illustrates the creation of a 3D part by extruding a sketch and accessing its geometry sequence members like edges.
```APIDOC
## POST /api/part/create
### Description
This endpoint demonstrates creating a 3D deformable body by extruding a rectangular sketch and accessing the sequence of edges.
### Method
POST
### Endpoint
/api/part/create
### Parameters
#### Request Body
- **modelName** (string) - Required - The name of the model to create the part in.
- **partName** (string) - Required - The name for the new part.
- **sketchProfile** (object) - Required - Defines the sketch profile (e.g., a rectangle with `point1` and `point2`).
- **extrusionDepth** (float) - Required - The depth to extrude the sketch.
### Request Example
```json
{
"modelName": "Body",
"partName": "Switch",
"sketchProfile": {
"type": "rectangle",
"point1": [0.0, 0.0],
"point2": [70.0, 70.0]
},
"extrusionDepth": 20.0
}
```
### Response
#### Success Response (200)
- **part** (object) - Details of the created part, including its members.
- **part.edges** (EdgeArray) - A sequence of Edge objects representing the edges of the part.
#### Response Example
```json
{
"part": {
"name": "Switch",
"dimensionality": "THREE_D",
"type": "DEFORMABLE_BODY",
"edges": [
{
"type": "Edge",
"members": ["pointsOn"]
}
],
"numberOfEdges": 12
}
}
```
```
--------------------------------
### Assembly and Part Instances
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/write.md
Documentation for accessing the root assembly and creating instances of parts within the assembly.
```APIDOC
## Assembly and Part Instances
### Description
This section explains how to access the root assembly and create instances of previously defined parts.
### Methods
#### `odb.rootAssembly`
- **Description**: Accesses the root assembly object of the output database.
#### `assembly.Instance`
- **Description**: Creates a part instance within the assembly.
- **Parameters**:
- `name` (string) - Required - The name of the instance.
- `object` (Part object) - Required - The part object to instance.
- `localCsys` (object) - Optional - Specifies the local coordinate system for the instance.
### Request Example
```python
a = odb.rootAssembly
instance1 = a.Instance(name="part-1-1", object=part1)
```
### Response
#### Success Response (200)
- **Instance Object**: The newly created part instance.
```
--------------------------------
### Python List Initialization and Heterogeneous Elements
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Demonstrates the creation of lists in Python, including lists with homogeneous elements (integers, floats) and heterogeneous elements (mix of types).
```python
>>> myIntegerList = [7, 6, 5, 4]
>>> myFloatList = [7.1, 6.5, 5.3, 4.8]
>>> myList = [1, 2.5, "steel"]
```
--------------------------------
### C++ ABQmain Entry Point for Abaqus Programs
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/compile-link.md
This C++ code demonstrates the required ABQmain function, which serves as the entry point for Abaqus postprocessing programs. Arguments passed during execution are received by this function. It requires the odb_API.h header.
```c++
#include
int ABQmain(int argc, char **argv) {
// Insert user code here
return 0;
}
```
--------------------------------
### Python Boolean Example
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/types.md
Illustrates the basic usage and type checking of a standard Python Boolean value. This shows how to declare and verify a boolean variable in Python.
```python
>>> myPythonBoolean = True
>>> type(myPythonBoolean)
```
--------------------------------
### Create Material and Assign Properties
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Defines a material with elastic properties and density. This is a fundamental step in defining the material behavior for simulation.
```Python
material = model.Material(name='material')
material.Elastic(table=((1000, 0.2), ))
material.Density(table=((2500, ), ))
```
--------------------------------
### Complete Abaqus Output Script for Data Extraction
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
A comprehensive Python script for Abaqus that performs the entire process of opening an ODB file, extracting nodal displacement data ('U3'), and saving it to a CSV file. It includes necessary imports and functions for automation.
```Python
from abaqus import *
from abaqusConstants import *
from driverUtils import *
import visualization
import numpy as np
executeOnCaeStartup()
# Open output database
odb = session.openOdb('Job-1.odb')
session.viewports['Viewport: 1'].setValues(displayedObject=odb)
# Extract output data
dataList = session.xyDataListFromField(odb=odb, outputPosition=NODAL,
variable=(('U', NODAL, ((COMPONENT, 'U3'),)),),
nodeSets=('INSTANCE.SET-TOP', ))
data = np.array(dataList[0])
np.savetxt('data.csv', data, header='time,U3', delimiter=',', comments='')
```
--------------------------------
### Sequence Slicing in Python
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Demonstrates how to extract sub-sequences (slices) from lists and strings using slice notation `[m:n]`. Covers default start and end values.
```python
myList = [0, 1, 2, 3, 4]
print(myList[1:4])
myString = "linear load"
print(myString[7:])
print(myString[:6])
```
--------------------------------
### Create and Write Abaqus Job Input File using abqpy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/tutorials.md
Creates an Abaqus job and writes the input file for the simulation. The job is defined with a name and the associated model. Writing the input file is a crucial step before submitting the job for analysis.
```Python
job = mdb.Job(name='Job-1', model='Model-1')
job.writeInput()
```
--------------------------------
### ODB Filter Program Prompt Example
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/examples.md
Illustrates the interactive prompt from the odbFilter program, requesting the user to specify the frame increment for data copying between output databases.
```shell
Results from ODB : ringshell.odb will be filtered &
written
to ODB: ringshell_datacheck
By default only the first & last increment of a step will
be saved
For each step enter the increment between frames
for example : 3 => frames 0,3,6,..,lastframe will be saved
STEP Step-1 has 101 Frames
Enter Increment between frames
```
--------------------------------
### Create and Submit Analysis Job in Abqpy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/cantilever.md
This code creates an analysis job for the beam model, specifies its name and description, and then submits it for execution. It also includes a command to wait for the job to complete.
```Python
jobName = "beam_tutorial"
myJob = mdb.Job(name=jobName, model="Beam", description="Cantilever beam tutorial")
myJob.submit()
myJob.waitForCompletion()
```
--------------------------------
### Example: Monitor All Abaqus Messages
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/interact.md
This Python script demonstrates how to monitor all messages from Abaqus/Standard or Abaqus/Explicit analyses and print them to the Abaqus/CAE command line. It utilizes the `addMessageCallback` method with `ANY_JOB` and `ANY_MESSAGE_TYPE` constants.
```python
"""
simpleMonitor.py
Print all messages issued during an Abaqus;
analysis to the Abaqus/CAE command line interface
"""
from abaqus import *
from abaqusConstants import *
from jobMessage import ANY_JOB, ANY_MESSAGE_TYPE
```
--------------------------------
### Use math module functions (import math)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/programming.md
This code snippet illustrates importing the entire 'math' module and then accessing its functions and constants using the 'math.' qualifier. This method prevents name collisions and clearly indicates the origin of the functions. It demonstrates calculating a value using 'math.sin()' and an approximation of pi.
```python
import math
x = 22.0 / (7.0 * 4.0)
math.sin(x)
```
--------------------------------
### Create FieldOutput Object (C++)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/style.md
Provides an example of creating a 'FieldOutput' object using its constructor in the Abaqus C++ API. This involves specifying the name, description, and type of the field output to be created.
```cpp
odb_StepContainer stepCon = odb.steps(); odb_Step step = stepCon["Side load"]; odb_SequenceFrame frameSeq = step.frames(); odb_Frame frame = frameSeq.Get(frameSeq.Size() - 1); odb_FieldOutput& myFieldOutput = frame.FieldOutput("S", "stress", odb_Enum::TENSOR_3D_FULL);
```
--------------------------------
### Verify Abaqus/CAE MDB Initialization (Python)
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/extending.md
This function checks if the application data exists in the MDB. If not, it calls `initializeMdb` to set up the MDB. It's designed to be called after Abaqus/CAE starts and registers itself using `customKernel.setVerifyMdb`.
```python
def verifyMdb(mdbAppData):
# If there is no appData, initialize the MDB.
#
if mdbAppData == None:
initializeMdb()
return
# If my application is not in appData, initialize the MDB.
#
if not mdbAppData.has_key(myAppName):
initializeMdb()
return
# Perform any checks on the appData or customData here
# Set the verifyMdb method for the application.
# setVerifyMdb may be called only once per application name.
#
customKernel.setVerifyMdb(myAppName, verifyMdb)
```
--------------------------------
### Run odbMaxMises Script from System Prompt
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/python/examples.md
This command demonstrates how to execute the `odbMaxMises.py` script from the system prompt. It specifies the output database file and an optional element set to search within. Ensure strings with spaces are quoted.
```sh
abaqus python odbMaxMises.py -odb viewer_tutorial.odb \
-elset "ALL ELEMENTS"
```
--------------------------------
### Fetch Benchmark Input File
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/output/cpp/examples.md
Retrieves the benchmark input file (ringshell.inp) used in the example for demonstrating output database filtering. This file is necessary to generate the large output database.
```shell
abaqus fetch job=ringshell.inp
```
--------------------------------
### Abaqus: Creating Viewport with Keyword Arguments
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/python-abaqus/style.md
Demonstrates creating a new Viewport object using keyword arguments for clarity and flexibility in the Abaqus Scripting Interface.
```python
newViewport = session.Viewport(name="myViewport", origin=(10, 10), width=100, height=50)
```
--------------------------------
### Python Control Flow: While Loop
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Provides an example of a while loop in Python that iteratively updates a 'load' variable until a condition is met. It demonstrates how to modify variables within a loop and print their values in each iteration.
```python
>>> load = 10
>>> length = 3
>>> while load < 1e4:
... load = load * length
... print(load)
...
```
--------------------------------
### Create Part Instance in Abqpy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/cantilever.md
This snippet shows how to create an instance of a part within an assembly. It requires an existing model and part object, and specifies the instance name and whether it's dependent.
```Python
myAssembly = myModel.rootAssembly
myInstance = myAssembly.Instance(name="beamInstance", part=myBeam, dependent=OFF)
```
--------------------------------
### Python Variable Type Determination using type()
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Shows how to use the built-in type() function in Python to determine the data type of a variable. Examples include float, integer, and string types.
```python
>>> a = 2.375
>>> type(a)
>>> a = 1
>>> type(a)
>>> a = "chamfer"
>>> type(a)
```
--------------------------------
### Fetch Abaqus Analysis Scripts
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/examples/sensitivity.md
This command line utility retrieves necessary Python scripts for running the skew sensitivity analysis in Abaqus. It requires the Abaqus environment to be set up.
```sh
abaqus fetch job=skewExample
abaqus fetch job=skewExampleUtils
```
--------------------------------
### Python Loop Control: break Statement
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/introduction/python-basics.md
Demonstrates the 'break' statement in Python, which is used to exit a loop prematurely. The example shows a while loop that continuously prompts the user for input and breaks when the input is '0'.
```python
>>> while 1:
... x = raw_input("Enter a number or 0 to quit:")
... if x == "0":
... break
... else:
... print(x)
...
```
--------------------------------
### Accessing Abaqus Objects via Object Model Hierarchy
Source: https://github.com/zy111x/abqpy/blob/2024/docs/source/user/python/use-scripts/object-model.md
Illustrates accessing specific Abaqus objects using their defined ownership hierarchy in Python. This example shows how to navigate from the Mdb object down to a specific Cell object.
```python
cell4 = mdb.models["block"].parts["crankcase"].cells[4]
```