Skip to content

Commit 8d2b6ab

Browse files
committed
additional fixes for *SMAT
1 parent 0f9987a commit 8d2b6ab

File tree

6 files changed

+45
-25
lines changed

6 files changed

+45
-25
lines changed

docs/loading_km.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
Working with a ANSYS Full File (full)
22
=====================================
3-
The ANSYS full file is a FORTRAN formatted binary file containing the mass and stiffness from an ANSYS analysis. Using pyansys it can be loaded into memory as either a sparse or full matrix.
3+
The ANSYS full file is a FORTRAN formatted binary file containing the
4+
mass and stiffness from an ANSYS analysis. Using pyansys it can be
5+
loaded into memory as either a sparse or full matrix.
46

57

68
Reading a Full File
79
-------------------
8-
This example reads in the mass and stiffness matrices associated with the above example. ``load_km`` sorts degrees of freedom such that the nodes are ordered from minimum to maximum, and each degree of freedom (i.e. X, Y, Z), are sorted within each node. The matrices ``k`` and ``m`` are sparse by default, but if ``scipy`` is not installed, or if the optional parameter ``as_sparse=False`` then they will be full numpy arrays.
9-
10-
By default ``load_km`` outputs the upper triangle of both matrices. The constrained nodes of the analysis can be identified by accessing ``fobj.const`` where the constrained degrees of freedom are True and all others are False. This corresponds to the degrees of reference in ``dof_ref``.
11-
12-
By default dof_ref is unsorted. To sort these values, set ``sort==True``. It is enabled for this example to allow for plotting of the values later on.
10+
This example reads in the mass and stiffness matrices associated with
11+
the above example. ``load_km`` sorts degrees of freedom such that the
12+
nodes are ordered from minimum to maximum, and each degree of freedom
13+
(i.e. X, Y, Z), are sorted within each node. The matrices ``k`` and
14+
``m`` are sparse by default, but if ``scipy`` is not installed, or if
15+
the optional parameter ``as_sparse=False`` then they will be full
16+
numpy arrays.
17+
18+
By default ``load_km`` outputs the upper triangle of both matrices.
19+
The constrained nodes of the analysis can be identified by accessing
20+
``fobj.const`` where the constrained degrees of freedom are True and
21+
all others are False. This corresponds to the degrees of reference in
22+
``dof_ref``.
23+
24+
By default dof_ref is unsorted. To sort these values, set
25+
``sort==True``. It is enabled for this example to allow for plotting
26+
of the values later on.
1327

1428
.. code:: python
1529
@@ -22,14 +36,16 @@ By default dof_ref is unsorted. To sort these values, set ``sort==True``. It i
2236
dof_ref, k, m = full.load_km(sort=True)
2337
2438
25-
ANSYS only stores the upper triangular matrix in the full file. To make the full matrix:
39+
ANSYS only stores the upper triangular matrix in the full file. To
40+
make the full matrix:
2641

2742
.. code:: python
2843
2944
k += sparse.triu(k, 1).T
3045
m += sparse.triu(m, 1).T
3146
32-
If you have ``scipy`` installed, you can solve solve for the natural frequencies and mode shapes of a system.
47+
If you have ``scipy`` installed, you can solve solve for the natural
48+
frequencies and mode shapes of a system.
3349

3450
.. code:: python
3551

docs/mapdl/conversion.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ some commands require and will break the CORBA server connection.
4747
Also note that APDL macros that use ``*CREATE`` have been replaced
4848
with a python function. This will make the code easier to debug
4949
should it be necessary to insert a break point in the code.
50+
51+
52+
Convert Script Description
53+
--------------------------
54+
.. autofunction:: pyansys.convert.convert_script

pyansys/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
88
"""
99

10+
class VersionError(ValueError):
11+
"""Raised when MAPDL is the wrong version"""
12+
13+
def __init__(self, msg='Invalid MAPDL version'):
14+
ValueError.__init__(self, msg)
15+
1016
class MapdlRuntimeError(RuntimeError):
1117
"""Raised when MAPDL passes an error"""
1218
pass

pyansys/launcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pexpect
1313

1414
from pyansys.misc import is_float, random_string
15-
from pyansys.errors import LockFileException
15+
from pyansys.errors import LockFileException, VersionError
1616

1717
# settings directory
1818
SETTINGS_DIR = appdirs.user_data_dir('pyansys')
@@ -663,7 +663,7 @@ def check_mode(mode, version):
663663

664664
if mode == 'corba':
665665
if version < 170:
666-
raise ValueError('CORBA AAS mode requires MAPDL v17.0 or newer.')
666+
raise VersionError('CORBA AAS mode requires MAPDL v17.0 or newer.')
667667
# elif version > 20.1 and os.name == 'nt':
668668
# raise ValueError('CORBA AAS mode on Windows requires MAPDL 2020R1'
669669
# ' or earlier.')
@@ -679,7 +679,7 @@ def check_mode(mode, version):
679679
mode = 'corba'
680680
else:
681681
if os.name == 'nt':
682-
raise RuntimeError('Running MAPDL as a service requires '
682+
raise VersionError('Running MAPDL as a service requires '
683683
'v17.0 or greater on Windows.')
684684
mode = 'console'
685685

pyansys/mapdl.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ def mesh(self):
335335
"""
336336
return self._mesh
337337

338-
# @property
339-
# def _mesh(self): # pragma: no cover
340-
# """Implemented by child class"""
341-
# raise NotImplementedError('Implemented by child class')
342-
343338
@property
344339
@supress_logging
345340
def _mesh(self):

pyansys/mapdl_functions.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45355,9 +45355,6 @@ def hbmat(self, fname="", ext="", form="", matrx="", rhs="", mapping="",
4535545355
ext
4535645356
Filename extension (eight-character maximum).
4535745357

45358-
--
45359-
Unused field.
45360-
4536145358
form
4536245359
Specifies format of output matrix file:
4536345360

@@ -45459,7 +45456,7 @@ def hbmat(self, fname="", ext="", form="", matrx="", rhs="", mapping="",
4545945456
cannot be mapped directly to a node number or particular degree of
4546045457
freedom.
4546145458
"""
45462-
command = "HBMAT,%s,%s,%s,%s,%s,%s" % (str(fname), str(ext), str(form), str(matrx), str(rhs), str(mapping))
45459+
command = "HBMAT,%s,%s,,%s,%s,%s,%s" % (str(fname), str(ext), str(form), str(matrx), str(rhs), str(mapping))
4546345460
return self.run(command, **kwargs)
4546445461

4546545462
def sfdele(self, nlist="", lab="", **kwargs):
@@ -59806,7 +59803,7 @@ def edhgls(self, hgco="", **kwargs):
5980659803
command = "EDHGLS,%s" % (str(hgco))
5980759804
return self.run(command, **kwargs)
5980859805

59809-
def smat(self, matrix="", type="", method="", val1="", val2="", val3="",
59806+
def smat(self, matrix="", type="", method="", val1="", val2="", val3="", val4="",
5981059807
**kwargs):
5981159808
"""APDL Command: *SMAT
5981259809

@@ -59827,9 +59824,10 @@ def smat(self, matrix="", type="", method="", val1="", val2="", val3="",
5982759824

5982859825
Copy an existing matrix. - Import the matrix from a file.
5982959826

59830-
val1, val2, val3
59831-
Additional input. The meaning of Val1 through Val3 will vary
59832-
depending on the specified Method. See details below.
59827+
val1, val2, val3, val4
59828+
Additional input. The meaning of Val1 through Val3 will
59829+
vary depending on the specified Method. See in your ansys
59830+
documentation.
5983359831

5983459832
Notes
5983559833
-----
@@ -59845,7 +59843,7 @@ def smat(self, matrix="", type="", method="", val1="", val2="", val3="",
5984559843
For more information about .FULL file contents, see the HBMAT in the
5984659844
Command Reference.
5984759845
"""
59848-
command = "*SMAT,%s,%s,%s,%s,%s,%s" % (str(matrix), str(type), str(method), str(val1), str(val2), str(val3))
59846+
command = "*SMAT,%s,%s,%s,%s,%s,%s,%s" % (str(matrix), str(type), str(method), str(val1), str(val2), str(val3), str(val4))
5984959847
return self.run(command, **kwargs)
5985059848

5985159849
def hpgl(self, kywrd="", opt1="", opt2="", **kwargs):

0 commit comments

Comments
 (0)