Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions test/MHD/ShearingBox/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ double Analysis::ShwaveAmplitude(const int field,
const int nx,
const int ny,
const int nz,
const real t)
const real t,
const real phaseShift = 0.0)
/*
* compute the weighted average: int dphi dz rho *infield/int dphi dz rho
*
Expand All @@ -74,7 +75,7 @@ double Analysis::ShwaveAmplitude(const int field,
real z = d->x[KDIR](k);
real wave = sin(2.0*M_PI*( (nx-ny*shear*t)*x
+ ny*y
+ nz*z));
+ nz*z ) + 2*phaseShift*M_PI);
q += wave*d->Vc(field,k,j,i);
}
}
Expand Down Expand Up @@ -159,9 +160,9 @@ void Analysis::PerformAnalysis(DataBlock &data) {
WriteField(ShwaveAmplitude(VX1, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(VX2, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(VX3, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(BX1, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(BX2, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(BX3, 0, 1, 2, data.t) );
WriteField(ShwaveAmplitude(BX1, 0, 1, 2, data.t, -0.25));
WriteField(ShwaveAmplitude(BX2, 0, 1, 2, data.t, -0.25));
WriteField(ShwaveAmplitude(BX3, 0, 1, 2, data.t, -0.25));


if(idfx::prank==0) {
Expand Down
3 changes: 2 additions & 1 deletion test/MHD/ShearingBox/analysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Analysis {
const int,
const int,
const int,
const real);
const real,
const real);
DataBlockHost *d;
Grid *grid;

Expand Down
17 changes: 15 additions & 2 deletions test/MHD/ShearingBox/python/testidefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def rhs(t, y, Omega, q, B0y, B0z, k0x, k0y, k0z):
args, unknown = parser.parse_known_args()


# initial condition: vr=1, rest is 0, mode initial is nx=0, ny=1, nz=5)
# initial condition: vr=1, rest is 0, mode initial is nx=0, ny=1, nz=2)
y = solve_ivp(
rhs,
[0, 30],
Expand Down Expand Up @@ -103,6 +103,9 @@ def rhs(t, y, Omega, q, B0y, B0z, k0x, k0y, k0z):
(V["vx"] / v0 - y.sol(V["t"])[0, :]) ** 2
+ (V["vy"] / v0 - y.sol(V["t"])[1, :]) ** 2
+ (V["vz"] / v0 - y.sol(V["t"])[2, :]) ** 2
+ (V["bx"] / v0 - y.sol(V["t"])[3, :]) ** 2
+ (V["by"] / v0 - y.sol(V["t"])[4, :]) ** 2
+ (V["bz"] / v0 - y.sol(V["t"])[5, :]) ** 2
)


Expand All @@ -122,6 +125,16 @@ def rhs(t, y, Omega, q, B0y, B0z, k0x, k0y, k0z):
plt.legend()
plt.xlabel("t")

plt.figure(2)
plt.plot(V["t"], V["bx"] / v0, "r-", label=r"$b_{R}$")
plt.plot(V["t"], y.sol(V["t"])[3, :], "r--")
plt.plot(V["t"], V["by"] / v0, "b-", label=r"$b_{\varphi}$")
plt.plot(V["t"], y.sol(V["t"])[4, :], "b--")
plt.plot(V["t"], V["bz"] / v0, "g-", label=r"$b_{z}$")
plt.plot(V["t"], y.sol(V["t"])[5, :], "g--")
plt.legend()
plt.xlabel("t")

# plot error
plt.figure()
plt.semilogy(V["t"], error)
Expand All @@ -134,7 +147,7 @@ def rhs(t, y, Omega, q, B0y, B0z, k0x, k0y, k0z):
err = np.mean(error)
print("Error=", err)

if err < 0.03:
if err < 0.04:
print("SUCCESS")
sys.exit(0)
else:
Expand Down
Loading