Skip to content

Commit a9ffb97

Browse files
committed
First commit
0 parents  commit a9ffb97

File tree

11 files changed

+1287
-0
lines changed

11 files changed

+1287
-0
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Compiled source #
2+
###################
3+
*.pyc
4+
*.pyd
5+
*.c
6+
*.cpp
7+
*.so
8+
*.o
9+
10+
# OS generated files #
11+
######################
12+
.fuse_hidden*
13+
*~
14+
15+
# Pip generated folders #
16+
#########################
17+
pyansys.egg-info/
18+
build/
19+
dist/

LICENSE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2016 Alex Kaszynski
3+
4+
"Software" refers to python module ANSYScdb and all python and cython source code within.
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9+
10+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.rst

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
ANSYScdb
2+
========
3+
4+
Python module to extract data from ANSYS binary files and to display
5+
them if vtk is installed. Currently only supports (*.rst) files.
6+
7+
Installation
8+
------------
9+
10+
From source directory
11+
12+
``pip install .``
13+
14+
or
15+
16+
``python setup.py install``
17+
18+
License
19+
-------
20+
21+
ANSYScdb is licensed under the MIT license. The full statement is
22+
provided in the file named ``LICENSE``.
23+
24+
Dependencies
25+
------------
26+
27+
Required: ``numpy``, ``ANSYScdb``. Optional: ``vtk``
28+
29+
Minimum requirements are numpy to extract results from a results file. To
30+
convert the raw data to a VTK unstructured grid, vtk 5.0 or greater must
31+
be installed with Python bindings.
32+
33+
Tests
34+
-----
35+
36+
Test installation with the following from Python
37+
38+
.. code:: python
39+
40+
from pyansys import Tests
41+
42+
# Load a hexahedral beam modal analysis result file
43+
Tests.Reader.Load()
44+
45+
# Display first bending mode of that beam
46+
Tests.Reader.Display()
47+
48+
49+
Example Code
50+
------------
51+
52+
Assumes you have the example files . Otherwise, replace
53+
‘Beam.cdb’ with your own blocked \*.cdb file.
54+
55+
.. code:: python
56+
57+
# Load the reader from pyansys
58+
from pyansys import Reader
59+
60+
# Create result reader object
61+
fobj = Reader.ResultReader('file.rst')
62+
63+
# Get mode frequencies
64+
freqs = fobj.tvalues
65+
66+
# Get the node numbers in this result file
67+
nnum = fobj.nnum
68+
69+
# Get the mode shape at mode 7 (ANSYS result 7)
70+
disp = fobj.GetResult(6) # uses 0 based indexing
71+
72+
# Load CDB (necessary for display)
73+
fobj.LoadCDB('mesh.cdb')
74+
75+
# Plot the displacement of Mode 41 in the x direction
76+
fobj.PlotDisplacement(40, 'x')
77+

pyansys/Interface.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import numpy as np
3+
4+
5+
def Run(inputfile, jobname='file', nproc=4, outname='output.txt', memory=0,
6+
batch=False):
7+
""" Runs ANSYS """
8+
9+
# Check if input file exists
10+
if not os.path.isfile(inputfile):
11+
raise Exception('Input file does not exist')
12+
13+
if os.path.isfile(jobname + '.lock'):
14+
raise Exception('Lock file exists for jobname: ' + jobname)
15+
16+
options = ''
17+
options += '-j {:s} '.format(jobname)
18+
options += '-np {:d} '.format(nproc)
19+
options += '-o {:s} '.format(outname)
20+
options += '-i {:s} '.format(inputfile)
21+
if batch:
22+
options += '-b '
23+
24+
if memory:
25+
options += '-m {:d} '.format(memory)
26+
27+
command = "unshare -n -m -- sh -c 'sudo ifconfig lo up; /usr/ansys_inc/v150/ansys/bin/ansys150 {:s}'".format(options)
28+
29+
c = os.system(command)
30+
return c
31+

0 commit comments

Comments
 (0)