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.