ansys.dyna.core.solver.dynasolver.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.
- Parameters:
- Returns:
Aninstanceoftheclient,whichcanbeusedtocommunicatewiththegRPCserverrunningatthegivenhostnameandport.TheclientcantheninteractwithLS-DYNAviagRPC.
- hostname = 'localhost'#
- port = '5000'#
- pim_client = None#
- remote_instance = None#
- working_dir = None#
- stub#
- logger#
- static get_appdata_path()#
- static grpc_local_server_on() bool#
Check if the server is launched locally.
- Returns:
- bool
Truewhen successful,Falsewhen failed.
- list_files(subname=None)#
Get size information about one or more files in the LS-DYNA working directory.
- 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:
Apairof3-tuplesarereturned,givingthe(x, y, z)coordinatesandvelocitiesofthenode.Ifthenodenumbergivendoesnotexistinthemodel,then(None, None)isreturned.
- 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.
- pull(fname)#
Provide an alias for the
downloadmethod for backward compatibility.
- download(fname)#
Download a file from the gRPC server.
- push(fname, workdir)#
Provide an alias for the
uploadmethod for backward compatibility.
- upload(fname)#
Upload a file to the LS-DYNA working directory.
- 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.
- 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
- run(args)#
Begin execution with the given string as the command-line arguments.
- Parameters:
- args
str Command line to pass to LS-DYNA.
- args
- setlc(lc, value)#
Set a load curve to a constant value.
- start(nproc)#
Start LS-DYNA.
The program starts and awaits further input. To begin a simulation, the
runcommand must used to send the command line arguments.After starting but before running, a
resumecommand can be sent to set a pause time or cycle.- Parameters:
- nproc
int Number of cores (MPI ranks) to run.
- nproc
- 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
- switch(args)#
Send a “sense switch” to LS-DYNA.
- 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
Queueinstance is returned. The queue holds raw blocks of text as returned by the server.2: A
Queueinstance is returned.The queue holds individual lines of text.
- queuesize
int,optional Size to use for the
Queueinstance if thehowparameter is set to a value greater than0.
- which
- Returns:
Ifthevalueforthehowparameterisgreaterthan0,aQueue instanceisreturned.Whenacalltotheq.get()methodreturnsNone,alldatahasbeenreturned.
- time()#
Get the current cycle count and simulation time.
- Returns:
A(cycle_count,simulation_time) pair.
- send(cmdin)#
Send one request to LS-DYNA using the command-line interface.
- Parameters:
- cmdin
str Command to send.
- cmdin
- Returns:
NoneThere 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.pyprogram.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.