119119
120120SESSION_ID_NAME = "__PYMAPDL_SESSION_ID__"
121121
122+ DEFAULT_TIME_STEP_STREAM = None
123+ DEFAULT_TIME_STEP_STREAM_NT = 500
124+ DEFAULT_TIME_STEP_STREAM_POSIX = 100
125+
122126# Retry policy for gRPC calls.
123127SERVICE_DEFAULT_CONFIG = {
124128 # see https://github.com/grpc/proposal/blob/master/A6-client-retries.md#retry-policy-capabilities
@@ -1069,7 +1073,8 @@ def _send_command(self, cmd: str, mute: bool = False) -> Optional[str]:
10691073 def _send_command_stream (self , cmd , verbose = False ) -> str :
10701074 """Send a command and expect a streaming response"""
10711075 request = pb_types .CmdRequest (command = cmd )
1072- metadata = [("time_step_stream" , "100" )]
1076+ time_step = self ._get_time_step_stream ()
1077+ metadata = [("time_step_stream" , str (time_step ))]
10731078 stream = self ._stub .SendCommandS (request , metadata = metadata )
10741079 response = []
10751080 for item in stream :
@@ -1775,13 +1780,14 @@ def input(
17751780 execution time.
17761781
17771782 Due to stability issues, the default time_step_stream is
1778- dependent on verbosity . The defaults are:
1783+ dependent on the OS MAPDL is running on . The defaults are:
17791784
1780- - ``verbose=True`` : ``time_step_stream=500``
1781- - ``verbose=False`` : ``time_step_stream=50 ``
1785+ - Windows : ``time_step_stream=500``
1786+ - Linux : ``time_step_stream=100 ``
17821787
17831788 These defaults will be ignored if ``time_step_stream`` is
1784- manually set.
1789+ manually set. See the *Examples* section to learn how to change
1790+ the default value globally.
17851791
17861792 orig_cmd : str, optional
17871793 Original command. There are some cases, were input is
@@ -1831,6 +1837,11 @@ def input(
18311837 >>> with mapdl.non_interactive:
18321838 mapdl.run("/input,inputtrigger,inp") # This inputs 'myinput.inp'
18331839
1840+ You can also change them globably using:
1841+
1842+ >>> from ansys.mapdl.core import mapdl_grpc
1843+ >>> mapdl_grpc.DEFAULT_TIME_STEP_STREAM=100 # in milliseconds
1844+
18341845 """
18351846 # Checking compatibility
18361847 # Checking the user is not reusing old api:
@@ -1911,18 +1922,14 @@ def input(
19111922 # are unclear
19121923 filename = self ._get_file_path (fname , progress_bar )
19131924
1914- if time_step_stream is not None :
1915- if time_step_stream <= 0 :
1916- raise ValueError ("``time_step_stream`` must be greater than 0``" )
1925+ time_step_stream = self ._get_time_step_stream (time_step_stream )
19171926
1918- if verbose :
1919- if time_step_stream is None :
1920- time_step_stream = 500
1921- metadata = [
1922- ("time_step_stream" , str (time_step_stream )),
1923- ("chunk_size" , str (chunk_size )),
1924- ]
1927+ metadata = [
1928+ ("time_step_stream" , str (time_step_stream )),
1929+ ("chunk_size" , str (chunk_size )),
1930+ ]
19251931
1932+ if verbose :
19261933 request = pb_types .InputFileRequest (filename = filename )
19271934 strouts = self ._stub .InputFileS (request , metadata = metadata )
19281935 responses = []
@@ -1934,13 +1941,8 @@ def input(
19341941 response = "\n " .join (responses )
19351942 return response .strip ()
19361943
1937- # otherwise, not verbose
1938- if time_step_stream is None :
1939- time_step_stream = 50
1940- metadata = [
1941- ("time_step_stream" , str (time_step_stream )),
1942- ("chunk_size" , str (chunk_size )),
1943- ]
1944+ ##
1945+ # Otherwise, not verbose
19441946
19451947 # since we can't directly run /INPUT, we have to write a
19461948 # temporary input file that tells MAPDL to read the input
@@ -2014,6 +2016,31 @@ def input(
20142016
20152017 return output
20162018
2019+ def _get_time_step_stream (
2020+ self , time_step : Optional [Union [int , float ]] = None
2021+ ) -> str :
2022+ """Return the time step for checking if MAPDL is done writing the
2023+ output to the file which later will be returned as response
2024+ """
2025+ if time_step is None :
2026+ if DEFAULT_TIME_STEP_STREAM is not None :
2027+ time_step = DEFAULT_TIME_STEP_STREAM
2028+ elif self .platform == "windows" :
2029+ time_step = DEFAULT_TIME_STEP_STREAM_NT
2030+ elif self .platform == "linux" :
2031+ time_step = DEFAULT_TIME_STEP_STREAM_POSIX
2032+ else :
2033+ raise ValueError (
2034+ f"The MAPDL platform ('{ self .platform } ') is not recognaised."
2035+ )
2036+
2037+ else :
2038+ if time_step <= 0 :
2039+ raise ValueError ("``time_step`` argument must be greater than 0``" )
2040+
2041+ self .logger .debug (f"The time_step argument is set to: { time_step } " )
2042+ return time_step
2043+
20172044 def _get_file_path (self , fname : str , progress_bar : bool = False ) -> str :
20182045 """Find files in the Python and MAPDL working directories.
20192046
0 commit comments