Reputation: 137
How can I loop the following to give me the values of sigma z for h where h is
h = np.array[0,3,0.1]
Instead of having to do the function over and over with h =1, h = 2... and so on 30 times
Here I just have what each value represents in case anyone is a bit confused
Here is the part I need to loop
Upvotes: 0
Views: 52
Reputation: 1350
Not entirely clear on the use case here. If you will always be doing the [0,3,0.1] range with a step of .1, maybe you don't have to expose --h to a user.
Assuming your function takes h and all the other values are default:
h = np.arange([0,3,0.1]) # I think you meant 'arange()' instead of 'array()' above
for impurity_val in h:
calculate_hamiltonian(h)
Otherwise, you can write a python script to generate a string by looping through the vals. The string will chain the commands, for example:
python ThreeSpinDriving.py --h 0 && ThreeSpinDriving --h 1 && ThreeSpinDriving -h 3
Upvotes: 1