Replies: 2 comments 4 replies
-
The most straight-forward way would probably to use a
|
Beta Was this translation helpful? Give feedback.
1 reply
-
In my case this solution works fine after minor corrections
1. from pde import PDE, FieldCollection, PlotTracker, ScalarField, UnitGrid, DataTracker <<-- add DataTracker 2. pde.DataTracker( <<--- DataTracker( omit pde.
Thank you!
On Tuesday, May 4, 2021, 12:50:55 PM CDT, David Zwicker ***@***.***> wrote:
The most straight-forward way would probably to use a DataTracker to call a custom function periodically.
Here is a modification of the example that shows the ideas in action:
from pde import PDE, FieldCollection, PlotTracker, ScalarField, UnitGrid
import matplotlib.pyplot as plt
# define the PDE
a, b = 1, 3
d0, d1 = 1, 0.1
eq = PDE(
{
"u": f"{d0} * laplace(u) + {a} - ({b} + 1) * u + u**2 * v",
"v": f"{d1} * laplace(v) + {b} * u - u**2 * v",
}
)
# initialize state
grid = UnitGrid([64, 64])
u = ScalarField(grid, a, label="Field $u$")
v = b / a + 0.1 * ScalarField.random_normal(grid, label="Field $v$")
state = FieldCollection([u, v])
def get_energy(data):
u, v = data
return (u**2 + v**2).integral
# simulate the pde
data_tracker = pde.DataTracker(get_energy, interval=1)
eq.solve(state, t_range=20, dt=1e-3, tracker=['progress', data_tracker])
plt.plot(data_tracker.times, data_tracker.data)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While simulating the Brusselator (with spatial coupling) with u(x, y, t) and v(x, y, t), I have to calculate the energy
W(t) = integral ((u ^ 2 + v ^ 2) dxdy) (or other analogous quantities) at times t < tFin. How do I access the local values u(x, y, t) and v(x, y, t) during the simulation (run-time) to have W(t) for the later use? Is there a general technique? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions