コード例 #1
0
ファイル: global_.py プロジェクト: gbtami/FatICS
def init():
    db.init()
    yield server.init()
    yield channel.init()
    yield filter_.init()
    var.init_vars()
    var.init_ivars()
    yield list_.init_lists()
    yield speed_variant.init()
コード例 #2
0
def run(conf):
    """Start the server."""

    with open(os.path.join(conf['datadir'], conf['pidfile']), 'w') as pid_file:
        pid_file.write(str(os.getpid()))

    if conf.getboolean('regtest'):
        bitcoin.SelectParams('regtest')
    else:
        raise Exception("Non-regnet use not supported")

    port = conf.getint('port')
    app.config['secret'] = b'correct horse battery staple' + bytes(str(port), 'utf8')
    app.config.update(conf)
    app.config['bitcoind'] = config.bitcoin_proxy(datadir=conf['datadir'])
    channel.init(app.config)
    lightning.init(app.config)
    app.run(port=port, debug=conf.getboolean('debug'), use_reloader=False,
            processes=3)
コード例 #3
0
ファイル: lightningserver.py プロジェクト: salis/Lightning
def run(conf):
    """Start the server."""

    with open(os.path.join(conf['datadir'], conf['pidfile']), 'w') as pid_file:
        pid_file.write(str(os.getpid()))

    if conf.getboolean('regtest'):
        bitcoin.SelectParams('regtest')
    else:
        raise Exception("Non-regnet use not supported")

    port = conf.getint('port')
    app.config['secret'] = b'correct horse battery staple' + bytes(
        str(port), 'utf8')
    app.config.update(conf)
    app.config['bitcoind'] = config.bitcoin_proxy(datadir=conf['datadir'])
    channel.init(app.config)
    lightning.init(app.config)
    app.run(port=port,
            debug=conf.getboolean('debug'),
            use_reloader=False,
            processes=3)
コード例 #4
0
ファイル: startup_test.py プロジェクト: huahbo/shadow-channel
#!/bin/py
#
# run the channel and create plots comparable to keefe (92)
#
import os
import sys
sys.path.append("..")
import channel 

# for plotting
import pylab as pl
import numpy as np

# reynolds number
channel.Re=2000

# invoke init
channel.init(100, 0, None)

C = channel.get_solution(0) * 0
channel.primal(C)

y, w = channel.quad()

for i in [0, 2, 10, 40, 100]:
    u = channel.spec2phys(i)
    pl.plot(y, u[0].mean(0).mean(1), '.-')

コード例 #5
0
ファイル: fd.py プロジェクト: huahbo/shadow-channel
# reynolds number
channel.Re=int(sys.argv[1])

# invoke init
n_steps = 10000

restart_file = '../keefe_runup_stage_5_qiqi.hd5'

for i_stage in range(1000000):
    next_restart = 'Re{0:04d}_{1:06d}.hd5'.format(channel.Re, i_stage)

    if not os.path.exists(next_restart):
        print('restarting from ', restart_file, ' writing to ', next_restart)
        sys.stdout.flush()

        channel.init(n_steps, 0, restart_file)
        
        u_mean, u2_mean = [], []
        for i in range(0, n_steps + 1, 400):
            U = channel.spec2phys(i)
            u_mean.append(U.mean(1).mean(2))
            u2_mean.append((U**2).mean(1).mean(2))
        
        u_mean, u2_mean = array(u_mean).mean(0), array(u2_mean).mean(0)
        
        savetxt('Re{0:04d}_{1:06d}.txt'.format(channel.Re, i_stage),
                vstack([u_mean, u2_mean]).T)
        channel.save_solution(next_restart, channel.get_solution(n_steps))

        channel.destroy()
コード例 #6
0
ファイル: testTanManu.py プロジェクト: huahbo/shadow-channel
import sys
sys.path.append("..")
import channel
from numpy import *

# TANGENT WITH FORCING
Re = 200
dRe = 1E-6
ru_steps = 0
n_steps = int(sys.argv[1])
i_restart = int(sys.argv[2])
restart = 'keefe_runup_stage_5.hd5' if i_restart else None
channel.dt = 0.01
channel.meanU = 1.0
channel.Re = Re
channel.init(n_steps, ru_steps, restart=restart)

# tangent 
IC = zeros_like(channel.get_solution(0))
channel.tangent(0, n_steps, IC, 1)

from pylab import *
y, w = channel.quad()
IU = channel.spec2phys(IC)
plot(y, IU[0].mean(0).mean(1))
savefig('testTanManu{0:06d}_restart{1:1d}'.format(n_steps, restart is not None))

# channel.destroy()
コード例 #7
0
ファイル: testAdj.py プロジェクト: huahbo/shadow-channel
import os
import sys
sys.path.append("..")
import channel
from numpy import *

restart_file = 'keefe_runup_stage_5_qiqi.hd5'
if not os.path.exists(restart_file):
    url = 'https://www.dropbox.com/s/8nqihkqf8sd4w8z/keefe_runup_stage_5.hd5'
    print('Please download\n{0}\nand name it\n{1}\n'.format(url, restart_file))

# Primal
n_steps = 100

channel.Re = 2000
channel.init(n_steps, ru_steps=0, restart=restart_file) # turbulent

# channel.Re = 100
# channel.init(n_steps, ru_steps=0, restart=None) # laminar
C = channel.get_solution(0)

# perturbation
IC = zeros(C.shape, complex)
IC[0,0,:,0] = random.normal(size=C.shape[2])
IC = random.normal(size=C.shape) + 0j
channel.tangent(0, 1, IC, 0)
IC0 = IC.copy()

# run tangent
print('tangent')
channel.tangent(1, n_steps-1, IC, 0)