I have a section of code that I am using to calculate magnetic fields and magnetic vector potentials. I do various things to calculate an inverse curl, but I'm getting stuck on a namespace issue in python and I'm not sure how to move forward.
The code (shortened a little) works like this
def main():
# define all my arrays
Ax = np.zeros(nx)
# call a function to update a particular component of the Ax
index = 50
update_A(Ax[index])
return Ax
def update_A(Axmm):
# do a calculation to get this new component
Axmm = some function
The update_A function is calculating the value as expected, but then isn't overwriting the element of Ax like I want it to. How can I get it to do the calculation and update the element of Ax that I've given it?
Ax[index] = calc_ new_A(Ax[index])most types in python are immutable, so you pass to function not "array cell", but just copy of array element and assignment has no effect to array