Is there anyway for us to call a python script within a dat file that includes a command line argument?
I have a python script that requires a command line argument and I want to iteratively call this script so I used the program call command but it does not recognize command line arguments so is there any alternative solution to that?
Hello,
It is possible to call a python file using the program call command (ex : program call “py_script.py”) but you need to establish the connection between python and fish arguments. To do so you might use :
python_argument = itasca.fish.get(“fish_argument”).
Hope it helps you.
Thank you for your responses. I figured out a way to do this in python without having to resort to FISH variables.
Let’s say i have a main function in a script (solve.py) where model solve command is called:
def main():
#Apply gravity load and solve to equilibrium
num_inc = 10 #set total number of increments
inc_size = 0.1 # 0.1 x 10 = 1.0 (the full application of loads)
p_1 = 0.0
p_2 = 0.0
for count in range(0,num_inc,1):
mult = inc_size
p1,p2 = main_loop_v2.main(mult,count) #Call the function that needs two arguments, where loads were incrementally applied
p_1 += p1
p_2 += p2
print("solving for p1 : {} N/m2 and p2 : {} N/m2".format(p_1,p_2))
dmax,vmax = getmaxdisp()
it.fish.set("maxdisp",dmax)
it.command("model solve mech ratio-local 1e-4")
it.command("model save")
Notice that I called main_loop_v2.py where the main function requires two arguments from
solve.py.
Would you kindly explain to me on how does the "Program Call’ function works? I tried to solve the same data file provided in the FLAC 3D example problems but it shows error in the same line where “Program call” is provided. I am not able to see the link of the program call anywhere. Please see the attached photo.
What was the error message shown in the Console pane again?
If the message were something along the lines of “File not found”, I would suggest checking the location where the project file for this example is saved. Please see the snapshot below.
Because I’m using 3DEC, the directory on my computer is:
C:\Program Files\Itasca\3DEC700\DataFiles3D\FLAC\ExampleApplications\EmbankmentLoad
Yours would probably be:
C:\Program Files\Itasca\FLAC3D700\DataFiles3D\FLAC\ExampleApplications\EmbankmentLoad
Thanks. But my error is like this. what could be the reason for this? I am running the same data file of the built in example but yet it is not running.