コード例 #1
0
ファイル: runtest.py プロジェクト: xj361685640/BOUT-dev
for zeff in zlist:
    # Create the input file, setting Zeff
    timestep = 5e3
    if zeff < 128:
        # reduce time-step. At large times these cases produce noise
        timestep = 1e3

    # Delete old output files
    shell("rm data/BOUT.dmp.*.nc")

    print("Running drift instability test, zeff = ", zeff)

    # Run the case
    s, out = launch_safe("./2fluid 2fluid:Zeff={} timestep={}".format(
        zeff, timestep),
                         nproc=nproc,
                         mthread=nthreads,
                         pipe=True)
    f = open("run.log." + str(zeff), "w")
    f.write(out)
    f.close()

    # Collect data
    Ni = collect("Ni", path="data", xind=2, yind=20, info=False)
    phi = collect("phi", path="data", xind=2, yind=20, info=False)

    zmax = collect("ZMAX", path="data", info=False)
    rho_s = collect("rho_s", path="data", info=False)
    wci = collect("wci", path="data", info=False)
    t_array = collect("t_array", path="data", info=False)
コード例 #2
0
ファイル: runtest.py プロジェクト: jenuis/BOUT-dev
    # Create the input file, setting Zeff
    # If we get passed Staggered or something like this, use staggered config file
    inp='BOUT_stag.inp' if 'stag' in [i.lower()[:4] for i in argv] else 'BOUT.inp'
    shell_safe("sed 's/Zeff = 128.0/Zeff = "+str(zeff)+"/g' "+inp+" > data/BOUT.inp")
    timestep = 5e3
    if zeff < 128:
        # reduce time-step. At large times these cases produce noise
        timestep = 1e3

    # Delete old output files
    shell("rm data/BOUT.dmp.*.nc")

    print("Running drift instability test, zeff = ", zeff)

    # Run the case
    s, out = launch_safe("./2fluid timestep="+str(timestep), runcmd=MPIRUN, nproc=nproc, mthread=nthreads, pipe=True)
    f = open("run.log."+str(zeff), "w")
    f.write(out)
    f.close()

    # Collect data
    Ni = collect("Ni", path="data", xind=2, yind=20, info=False)
    phi = collect("phi", path="data", xind=2, yind=20, info=False)

    zmax     = collect("ZMAX", path="data", info=False)
    rho_s    = collect("rho_s", path="data", info=False)
    wci      = collect("wci", path="data", info=False)
    t_array  = collect("t_array", path="data", info=False)

    dims = np.shape(Ni)
    nt = dims[0]
コード例 #3
0
ファイル: sinusoid.py プロジェクト: xj361685640/BOUT-dev
beta_max_list = [5, 10, 20, 40]
colors = ['k','b','g','r']

ngroups_list = [20, 40, 80]
syms = ['x', 'o', 'D']

for beta_max, color in zip(beta_max_list, colors):
    for ngroups, sym in zip(ngroups_list, syms):

        flux_ratio = []
        for Te in Telist:
            cmd = "./conduction-snb \"Te={0}+0.01*sin(y)\" Ne={1} mesh:length={2} snb:beta_max={3} snb:ngroups={4}".format(Te, Ne, length, beta_max, ngroups)

            # Run the case
            s, out = launch_safe(cmd, nproc=1, mthread=1, pipe=True)

            div_q = collect("Div_Q", path="data").ravel()
            div_q_SH = collect("Div_Q_SH", path="data").ravel()

            # Get the index of maximum S-H heat flux
            ind = np.argmax(div_q_SH)

            flux_ratio.append(div_q[ind] / div_q_SH[ind])

        plt.plot(lambda_ee_T / length, flux_ratio, '-'+sym+color, label=r"$\beta_{{max}}={0}, N_g={1}$".format(beta_max,ngroups))

plt.legend()
plt.xlabel(r"$\lambda_{ee,T} / L$")
plt.ylabel(r"$q / q_{SH}$")
plt.xscale("log")
コード例 #4
0
    ("boundary", "Model 2 (density, momentum)")
    ,("boundary-logn", "Model 3 (log density, momentum)")
    #,("../fci-wave-logn/boundary", "Model 5 (log density, velocity)")
    ]

# Change this to select no boundary or boundary cases
data = data_noboundary

if run:
    from boututils.run_wrapper import shell_safe, launch_safe, getmpirun
    
    shell_safe("make > make.log")
    MPIRUN=getmpirun()
    
    for path,label in data:
        launch_safe("./fci-wave -d "+path, runcmd=MPIRUN, nproc=nproc, pipe=False)

# Collect the results into a dictionary 
sum_n_B = {}

for path,label in data:
    n = collect("n", path=path)
    Bxyz = collect("Bxyz", path=path)

    time = collect("t_array", path=path)
    
    nt, nx, ny, nz = n.shape
    
    n_B = np.ndarray(nt)
    for t in range(nt):
        n_B[t] = np.sum(n[t,:,:,:] / Bxyz)
コード例 #5
0
ファイル: step.py プロジェクト: xj361685640/BOUT-dev
length = 6e-4 # Domain length in m

qe = 1.602176634e-19

import numpy as np
import matplotlib.pyplot as plt

from boututils.run_wrapper import build_and_log, launch_safe
from boutdata.collect import collect

path = "step"

build_and_log("Step SNB")
# Run the case
s, out = launch_safe("./conduction-snb -d " + path, nproc=1, mthread=1, pipe=True)

Te = collect("Te", path=path).ravel()

ny = len(Te)
dy = length / ny

position = (np.arange(ny) + 0.5) * length / ny

# Read divergence of heat flux
div_q = collect("Div_Q", path=path).ravel()
div_q_SH = collect("Div_Q_SH", path=path).ravel()

# Integrate the divergence of flux to get heat flux W/m^2
q = np.cumsum(div_q) * qe * dy
q_SH = np.cumsum(div_q_SH) * qe * dy
コード例 #6
0
ファイル: compare-density.py プロジェクト: jenuis/BOUT-dev
    ("boundary-logn", "Model 3 (log density, momentum)")
    #,("../fci-wave-logn/boundary", "Model 5 (log density, velocity)")
]

# Change this to select no boundary or boundary cases
data = data_noboundary

if run:
    from boututils.run_wrapper import shell_safe, launch_safe, getmpirun

    shell_safe("make > make.log")
    MPIRUN = getmpirun()

    for path, label in data:
        launch_safe("./fci-wave -d " + path,
                    runcmd=MPIRUN,
                    nproc=nproc,
                    pipe=False)

# Collect the results into a dictionary
sum_n_B = {}

for path, label in data:
    n = collect("n", path=path)
    Bxyz = collect("Bxyz", path=path)

    time = collect("t_array", path=path)

    nt, nx, ny, nz = n.shape

    n_B = np.ndarray(nt)
    for t in range(nt):
コード例 #7
0
data_boundary = [
    ("boundary", "Model 2 (density, momentum)"),
    ("boundary-logn", "Model 3 (log density, momentum)")
    #,("../fci-wave-logn/boundary", "Model 5 (log density, velocity)")
]

# Change this to select no boundary or boundary cases
data = data_noboundary

if run:
    from boututils.run_wrapper import shell_safe, launch_safe
    shell_safe("make > make.log")

    for path, label in data:
        launch_safe("./fci-wave -d " + path, nproc=nproc, pipe=False)

# Collect the results into a dictionary
sum_n_B = {}

for path, label in data:
    n = collect("n", path=path)
    Bxyz = collect("Bxyz", path=path)

    time = collect("t_array", path=path)

    nt, nx, ny, nz = n.shape

    n_B = np.ndarray(nt)
    for t in range(nt):
        n_B[t] = np.sum(n[t, :, :, :] / Bxyz)