Skip to content

Tracking/saving fields outside of those involved in a PDE #450

Answered by david-zwicker
iamlll asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for providing the code! I can reproduce the error, which is caused by a subtle behavior of py-pde. In essence, new state.append(div) actually also modifies state.fields and leads to the error. You could instead use

newstate = state.fields[:]   # create a copy of the list
newstate.append(div)

or just

newstate = state.fields[:] + [div]

to prevent this error!

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@iamlll
Comment options

@david-zwicker
Comment options

@iamlll
Comment options

@david-zwicker
Comment options

Answer selected by iamlll
@iamlll
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants