DynaSolver
#
- class ansys.dyna.core.solver.dynasolver.DynaSolver(hostname='localhost', port='5000', channel=None, server_path='')#
Provides the gRPC client-side of Ansys LS-DYNA.
Overview#
Get size information about one or more files in the LS-DYNA |
|
Get size information about a node in the model’s working directory. |
|
Pause LS-DYNA execution. |
|
Provide an alias for the |
|
Download a file from the gRPC server. |
|
Provide an alias for the |
|
Upload a file to the LS-DYNA working directory. |
|
Terminate the gRPC server program. This does not terminate LS-DYNA. |
|
Resume execution. |
|
Begin execution with the given string as the command-line arguments. |
|
Set a load curve to a constant value. |
|
Start LS-DYNA. |
|
Begin execution with the given string as the command-line arguments. |
|
Send a “sense switch” to LS-DYNA. |
|
Monitor the stdout or stderr of the running job. |
|
Get the current cycle count and simulation time. |
|
Send one request to LS-DYNA using the command-line interface. |
|
Read command lines from a file and execute them. |
Check if the server is launched locally. |
Import detail#
from ansys.dyna.core.solver.dynasolver import DynaSolver
Attribute detail#
- DynaSolver.hostname = 'localhost'#
- DynaSolver.port = '5000'#
- DynaSolver.pim_client = None#
- DynaSolver.remote_instance = None#
- DynaSolver.working_dir = None#
- DynaSolver.stub#
- DynaSolver.logger#
Method detail#
- static DynaSolver.get_appdata_path()#
- static DynaSolver.grpc_local_server_on() bool #
Check if the server is launched locally.
- Returns:
- bool
True
when successful,False
when failed.
- DynaSolver.list_files(subname=None)#
Get size information about one or more files in the LS-DYNA working directory.
- DynaSolver.node(n)#
Get size information about a node in the model’s working directory.
- Parameters:
- n
integer
User ID of a node in the model.
- n
- Returns:
A
pair
of
3-tuplesare
returned
,giving
the
(x, y, z)
coordinates
and
velocities
of
the
node.If
the
node
number
given
does
not
exist
in
the
model
,then
(None, None)
is
returned.
- DynaSolver.pause()#
Pause LS-DYNA execution.
Execution stops until told to resume or quit. Most
switch
” commands result in one cycle being executed so that the switch can be handled, and then LS-DYNA pauses again.
- DynaSolver.pull(fname)#
Provide an alias for the
download
method for backward compatibility.
- DynaSolver.download(fname)#
Download a file from the gRPC server.
- DynaSolver.push(fname, workdir)#
Provide an alias for the
upload
method for backward compatibility.
- DynaSolver.upload(fname)#
Upload a file to the LS-DYNA working directory.
- DynaSolver.quit()#
Terminate the gRPC server program. This does not terminate LS-DYNA.
If the server is running inside a container, it ignore this command and continues running.
- DynaSolver.resume(cycle=None, time=None)#
Resume execution.
- Parameters:
- cycle
integer
,optional
Cycle to pause execution on. The default is
None
.- time
float
,optional
Ssimulation time to pause execution at. The default is
None
.- This command can be given whether LS-DYNA is paused or running.
- LS-DYNA runs until the given cycle number or simulation time. If
- both are given, it stops based on whichever occurs first. If
- neither are given, it runs until termination or until paused.
- cycle
- DynaSolver.run(args)#
Begin execution with the given string as the command-line arguments.
- Parameters:
- args
str
Command line to pass to LS-DYNA.
- args
- DynaSolver.setlc(lc, value)#
Set a load curve to a constant value.
- DynaSolver.start(nproc)#
Start LS-DYNA.
The program starts and awaits further input. To begin a simulation, the
run
command must used to send the command line arguments.After starting but before running, a
resume
command can be sent to set a pause time or cycle.- Parameters:
- nproc
int
Number of cores (MPI ranks) to run.
- nproc
- DynaSolver.start_locally(preset='MPP', input='', nproc=1, memory=20)#
Begin execution with the given string as the command-line arguments.
- Parameters:
- args
str
Command line to pass to LS-DYNA.
- args
- DynaSolver.switch(args)#
Send a “sense switch” to LS-DYNA.
- DynaSolver.tail(which=1, how=2, queuesize=0)#
Monitor the stdout or stderr of the running job.
- Parameters:
- which
int
,optional
Which stream to monitor. The default is
1
, in which case stdout is used. Otherwise, stderr is used.- how
int
,optional
How to handle the file data. The default is
2
. Options are:0: The file contents are printed to stdout, and this method does not return until LS-DYNA terminates.
1: A
Queue
instance is returned. The queue holds raw blocks of text as returned by the server.2: A
Queue
instance is returned.The queue holds individual lines of text.
- queuesize
int
,optional
Size to use for the
Queue
instance if thehow
parameter is set to a value greater than0
.
- which
- Returns:
If
the
value
for
the
how
parameter
is
greater
than
0,a
Queue instance
is
returned.When
a
call
to
the
q.get()
method
returns
None
,all
data
has
been
returned.
- DynaSolver.time()#
Get the current cycle count and simulation time.
- Returns:
A
(cycle_count
,simulation_time
) pair.
- DynaSolver.send(cmdin)#
Send one request to LS-DYNA using the command-line interface.
- Parameters:
- cmdin
str
Command to send.
- cmdin
- Returns:
None
There is no data returned. Data that is returned from the underlying method call is just printed to the screen. This method is used to support the sample interactive
client.py
program.Description
Example
“list” then optional file name
list d3plot
“list” then optional file name
list d3plot
“node” user node number
node 43444
“pause” (no arguments)
pause
“download” then file name
download glstat
“upload” then file name
upload input.k
“quit” (no arguments)
quit
“resume” optional cycle and/or time
resume 5000 0.25
“run” then the command line
run i=input.k jobid=xx
“setlc” user load curve number and value
setlc 1075 0.245
“start” number of processors
start 5
“switch” then switch text
switch sw2
“tail” then 1 for stdout, 2 for stderr
tail 1
“time” (no arguments)
time.