Skip to content

Commit f6f5401

Browse files
committed
various doc fixes
1 parent 8d2b6ab commit f6f5401

File tree

5 files changed

+159
-60
lines changed

5 files changed

+159
-60
lines changed

pyansys/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# major, minor, patch
2-
version_info = 0, 43, 0
2+
version_info = 0, 43, 1
33

44
# Nice string for the version
55
__version__ = '.'.join(map(str, version_info))

pyansys/convert.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,19 @@ def convert_script(filename_in, filename_out, loglevel='INFO', auto_exit=True,
2727
Log level of the ansys object within the script.
2828
2929
auto_exit : bool, optional
30-
Adds a line to the end of the script to exit ANSYS. Default True.
30+
Adds a line to the end of the script to exit MAPDL. Default
31+
``True``.
3132
3233
line_ending : str, optional
3334
When None, automatically determined by OS being used.
34-
Acceptable inputs are:
35-
36-
- \n
37-
- \r\n
3835
3936
macros_as_functions : bool, optional
4037
Attempt to convert macros to python functions.
4138
4239
use_function_names : bool, optional
4340
Convert MAPDL functions to pyansys.Mapdl class methods. When
4441
True "K" will be converted to ``mapdl.k``. When False, it
45-
will be converted to ``mapdl.run('k').
42+
will be converted to ``mapdl.run('k')``.
4643
4744
Returns
4845
-------
@@ -64,7 +61,7 @@ def convert_script(filename_in, filename_out, loglevel='INFO', auto_exit=True,
6461

6562

6663
class FileTranslator():
67-
obj_name = 'ansys'
64+
obj_name = 'mapdl'
6865
indent = ''
6966
non_interactive = False
7067

@@ -83,7 +80,7 @@ def __init__(self, loglevel='INFO', line_ending=None, exec_file=None,
8380
self.comment = ''
8481

8582
self.write_header()
86-
self.initialize_ansys_object(loglevel, exec_file)
83+
self.initialize_mapdl_object(loglevel, exec_file)
8784

8885
def write_header(self):
8986
hinfo = 'Script generated by pyansys version %s' % pyansys.__version__
@@ -101,16 +98,19 @@ def save(self, filename):
10198
for line in self.lines:
10299
f.write(line)
103100

104-
def initialize_ansys_object(self, loglevel, exec_file):
101+
def initialize_mapdl_object(self, loglevel, exec_file):
105102
""" Initializes ansys object as lines """
106-
self.lines.append('import pyansys%s' % self.line_ending)
103+
core_module = 'pyansys'
104+
self.lines.append('from %s%s import launch_mapdl' % (core_module,
105+
self.line_ending))
107106
if exec_file:
108107
exec_file_parameter = '"%s", ' % exec_file
109108
else:
110109
exec_file_parameter = ''
111-
line = 'ansys = pyansys.launch_mapdl(%sloglevel="%s")%s' % (exec_file_parameter,
112-
loglevel,
113-
self.line_ending)
110+
line = '%s = launch_mapdl(%sloglevel="%s")%s' % (self.obj_name,
111+
exec_file_parameter,
112+
loglevel,
113+
self.line_ending)
114114
self.lines.append(line)
115115

116116
@property

pyansys/launcher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Module for launching MAPDL locally."""
2-
import pathlib
32
from glob import glob
43
import time
54
import subprocess

pyansys/mapdl.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,14 +1245,14 @@ def get(self, par="__floatparameter__", entity="", entnum="",
12451245
--------
12461246
Retreive the number of nodes
12471247
1248-
>>> value = ansys.get('val', 'node', '', 'count')
1248+
>>> value = mapdl.get('val', 'node', '', 'count')
12491249
>>> value
12501250
3003
12511251
12521252
Retreive the number of nodes using keywords. Note that the
12531253
parameter name is optional.
12541254
1255-
>>> value = ansys.get(entity='node', item1='count')
1255+
>>> value = mapdl.get(entity='node', item1='count')
12561256
>>> value
12571257
3003
12581258
@@ -1521,6 +1521,11 @@ def modal_analysis(self, method='lanb', nmode='', freqb='', freqe='', cpxmod='',
15211521
Calculate element results, reaction forces, energies, and
15221522
the nodal degree of freedom solution. Default ``False``.
15231523
1524+
Returns
1525+
-------
1526+
response : str
1527+
Output from MAPDL SOLVE command.
1528+
15241529
Examples
15251530
--------
15261531
Modal analysis using default parameters for the first 6 modes
@@ -1559,8 +1564,9 @@ def modal_analysis(self, method='lanb', nmode='', freqb='', freqe='', cpxmod='',
15591564
if elcalc:
15601565
self.mxpand(elcalc='YES')
15611566

1562-
self.solve()
1567+
out = self.solve()
15631568
self.finish()
1569+
return out
15641570

15651571
def run(self, command, write_to_log=True):
15661572
"""Runs APDL command
@@ -1762,6 +1768,15 @@ def get_array(self, entity='', entnum='', item1='', it1num='', item2='',
17621768
...
17631769
314., 315., 316., 317., 318., 319., 320., 321.])
17641770
1771+
List the displacement in the X direction for the first result
1772+
1773+
>>> mapdl.post1()
1774+
>>> mapdl.set(1, 1)
1775+
>>> disp_x = mapdl.get_array('NODE', item1='U', it1num='X')
1776+
array([ 0.01605306, -0.01605306, 0.00178402, -0.01605306,
1777+
...
1778+
-0.00178402, -0.01234851, 0.01234851, -0.01234851])
1779+
17651780
Notes
17661781
-----
17671782
Please reference your ANSYS help manual *VGET command tables

pyansys/parameters.py

Lines changed: 127 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,31 @@
2727

2828

2929
class Parameters():
30-
"""Collection of MAPDL parameters obtainable from the \*GET command"""
30+
"""Collection of MAPDL parameters obtainable from the \*GET command
31+
32+
Examples
33+
--------
34+
Simply list all parameters except for MAPDL MATH parameters
35+
36+
>>> mapdl.parameters
37+
ARR : ARRAY DIM (3, 1, 1)
38+
PARM_FLOAT : 20.0
39+
PARM_INT : 10.0
40+
PARM_LONG_STR : "stringstringstringstringstringst"
41+
PARM_STR : "string"
42+
PORT : 50052.0
43+
44+
Get a parameter
45+
46+
>>> mapdl.parameters['PARM_FLOAT']
47+
20.0
48+
49+
Get an array parameter
50+
51+
>>> mapdl.parameters['ARR']
52+
array([1., 2., 3.])
53+
54+
"""
3155

3256
def __init__(self, mapdl):
3357
if not isinstance(mapdl, _MapdlCore):
@@ -42,7 +66,7 @@ def _log(self):
4266
return self._mapdl._log
4367

4468
@property
45-
def routine(self):
69+
def routine(self) -> str:
4670
"""Current routine string as a string. For example ``"/PREP7"``
4771
4872
MAPDL Command: \*GET, ACTIVE, 0, ROUT
@@ -52,15 +76,15 @@ def routine(self):
5276
routine : str
5377
Routine as a string. One of:
5478
55-
- ``"Begin level"``
56-
- ``"PREP7"``
57-
- ``"SOLUTION"``
58-
- ``"POST1"``
59-
- ``"POST26"``
60-
- ``"AUX2"``
61-
- ``"AUX3"``
62-
- ``"AUX12"``
63-
- ``"AUX15"``
79+
- ``"Begin level"``
80+
- ``"PREP7"``
81+
- ``"SOLUTION"``
82+
- ``"POST1"``
83+
- ``"POST26"``
84+
- ``"AUX2"``
85+
- ``"AUX3"``
86+
- ``"AUX12"``
87+
- ``"AUX15"``
6488
6589
Examples
6690
--------
@@ -71,78 +95,139 @@ def routine(self):
7195
return ROUTINE_MAP[int(value)]
7296

7397
@property
74-
def units(self):
98+
def units(self) -> str:
7599
"""Units specified by /UNITS command.
76100
77101
Returns
78102
-------
79103
units : str
80-
Active Units. One of:- "USER"
81-
- "SI"
82-
- "CGS"
83-
- "BFT"
84-
- "BIN"
85-
- "MKS
86-
- "MPA"
87-
- "uMKS
104+
Active Units. One of:
105+
- ``"None"``
106+
- ``"USER"``
107+
- ``"SI"``
108+
- ``"CGS"``
109+
- ``"BFT"``
110+
- ``"BIN"``
111+
- ``"MKS``
112+
- ``"MPA"``
113+
- ``"uMKS"``
114+
115+
Examples
116+
--------
117+
>>> mapdl.parameters.units
118+
'NONE'
88119
"""
89120
value = self._mapdl.get_value("ACTIVE", item1="UNITS")
90121
return UNITS_MAP[int(value)]
91122

92123
@property
93-
def revision(self):
124+
def revision(self) -> float:
94125
"""MAPDL revision version.
95126
96-
MAPDL revision version as a float. For example ``20.2``.
127+
Examples
128+
--------
129+
>>> mapdl.parameters.revision
130+
20.2
97131
"""
98132
return float(self._mapdl.get_value("ACTIVE", item1="REV"))
99133

100134
@property
101-
def platform(self):
135+
def platform(self) -> str:
102136
"""The current platform.
103137
104-
Current platform. For example ``"LIN"`` for Linux.
138+
Examples
139+
--------
140+
>>> mapdl.parameters.platform
141+
'LIN'
105142
"""
106143
return self._mapdl.get_value("ACTIVE", item1="PLATFORM")
107144

108145
@property
109-
def csys(self):
110-
"""Active coordinate system"""
146+
def csys(self) -> int:
147+
"""Active coordinate system
148+
149+
Examples
150+
--------
151+
>>> mapdl.parameters.csys
152+
0
153+
"""
111154
return int(self._mapdl.get_value("ACTIVE", item1="CSYS"))
112155

113156
@property
114-
def dsys(self):
115-
"""Active display coordinate system"""
157+
def dsys(self) -> int:
158+
"""Active display coordinate system
159+
160+
Examples
161+
--------
162+
>>> mapdl.parameters.dsys
163+
0
164+
"""
116165
return int(self._mapdl.get_value("ACTIVE", item1="DSYS"))
117166

118167
@property
119-
def rsys(self):
120-
"""Active result coordinate system"""
168+
def rsys(self) -> int:
169+
"""Active result coordinate system
170+
171+
Examples
172+
--------
173+
>>> mapdl.parameters.rsys
174+
0
175+
"""
121176
return int(self._mapdl.get_value("ACTIVE", item1="RSYS"))
122177

123178
@property
124-
def esys(self):
125-
"""Active element coordinate system"""
179+
def esys(self) -> int:
180+
"""Active element coordinate system
181+
182+
Examples
183+
--------
184+
>>> mapdl.parameters.esys
185+
0
186+
"""
126187
return int(self._mapdl.get_value("ACTIVE", item1="ESYS"))
127188

128189
@property
129-
def section(self):
130-
"""Active section number"""
190+
def section(self) -> int:
191+
"""Active section number
192+
193+
Examples
194+
--------
195+
>>> mapdl.parameters.section
196+
1
197+
"""
131198
return int(self._mapdl.get_value("ACTIVE", item1="SECT"))
132199

133200
@property
134-
def material(self):
135-
"""Active material"""
201+
def material(self) -> int:
202+
"""Active material
203+
204+
Examples
205+
--------
206+
>>> mapdl.parameters.material
207+
1
208+
"""
136209
return int(self._mapdl.get_value("ACTIVE", item1="MAT"))
137210

138211
@property
139-
def real(self):
140-
"""Active real constant set"""
212+
def real(self) -> int:
213+
"""Active real constant set
214+
215+
Examples
216+
--------
217+
>>> mapdl.parameters.real
218+
1
219+
"""
141220
return int(self._mapdl.get_value("ACTIVE", item1="REAL"))
142221

143222
@property
144-
def type(self):
145-
"""Active element type"""
223+
def type(self) -> int:
224+
"""Active element type
225+
226+
Examples
227+
--------
228+
>>> mapdl.parameters.type
229+
1
230+
"""
146231
return int(self._mapdl.get_value("ACTIVE", item1="type"))
147232

148233
@property
@@ -198,8 +283,8 @@ def _set_parameter(self, name, value):
198283
name : str
199284
An alphanumeric name used to identify this parameter. Par
200285
may be up to 32 characters, beginning with a letter and
201-
containing only letters, numbers, and underscores. Examples:
202-
``"ABC" "A3X" "TOP_END"``.
286+
containing only letters, numbers, and underscores.
287+
Examples: ``"ABC" "A3X" "TOP_END"``.
203288
204289
"""
205290
if not isinstance(value, (str, int, float)):

0 commit comments

Comments
 (0)