In [1]:
import json
from copy import deepcopy
import numpy as np
In [2]:
with open('once-through.json') as f:
ot = json.load(f)
In [3]:
lwr = ot['simulation']['facility'][1]
In [4]:
lwr
Out[4]:
In [5]:
n_rx = 100
np.linspace(1, 40 * 12, n_rx, dtype=int)
Out[5]:
In [6]:
lwrs = []
for i, life in enumerate(np.linspace(1, 40 * 12, n_rx, dtype=int), 0):
l = deepcopy(lwr)
l['name'] = 'LWR-Init{0:02}'.format(i)
l['lifetime'] = int(life)
l['config']['Reactor']['cycle_step'] = 18 - int(life%18)
lwrs.append(l)
In [7]:
with open('initial-lwrs.json', 'w') as f:
json.dump(lwrs, f)
In [8]:
ifl = [{'number': '1', 'prototype': l['name']} for l in lwrs]
In [9]:
ifl[-1]
Out[9]:
In [10]:
with open('initial-facs.json', 'w') as f:
json.dump(ifl, f)
Nicely done
In [11]:
%matplotlib inline
import matplotlib.pyplot as plt
In [12]:
import cymetric as cym
In [30]:
db = cym.dbopen('ot.h5')
In [31]:
evaler = cym.Evaluator(db)
In [32]:
ts = evaler.eval('TimeSeriesPower')
In [33]:
import pandas as pd
In [34]:
df = pd.DataFrame({'Time': ts.Time.apply(lambda x: x//12),
'GWe': ts.Value.apply(lambda x: 1e-3*x/12)})
In [35]:
grouped = df.groupby('Time').sum()
In [36]:
grouped.plot()
Out[36]:
In [20]:
250000//12
Out[20]:
In [21]:
agn = ts[ts.AgentId == 190]
df = pd.DataFrame({'Time': agn.Time.apply(lambda x: x//12),
'GWe': agn.Value.apply(lambda x: 1e-3*x/12)})
grouped = df.groupby('Time').sum()
grouped.plot()
Out[21]:
In [22]:
1000 * 12 / 12
Out[22]:
In [87]:
0.7042 / 50
Out[87]:
In [40]:
0.1 / 50
Out[40]:
In [41]:
prod?
In [42]:
from math import prod
In [43]:
np.argsort?
In [46]:
np.argsort([10, 0, 20, -30])
Out[46]:
In [61]:
0.62 / 50
Out[61]:
In [59]:
N = np.asarray(np.ceil(4*(1.01)**np.arange(50)), dtype='f8')
In [60]:
np.prod(N)
Out[60]:
In [64]:
np.array([[1, 3, 7], [2, 6, 5]]).min(axis=0)
Out[64]:
In [67]:
np.arange(4, 7)[np.argwhere(np.arange(4, 7) == 6)]
Out[67]:
In [72]:
100 * abs(0.76348006066862628, 0.82555114773520399) / 50
In [73]:
pererr = lambda x, y: 100 *abs(x-y)/50
In [74]:
pererr(0.76348006066862628, 0.82555114773520399)
Out[74]:
In [75]:
pererr(0.73280025356580158, 0.76348006066862628)
Out[75]:
In [76]:
pererr(0.73280025356580158, 0.7461216596266379)
Out[76]:
In [77]:
np.cumprod?
In [81]:
np.cumprod([1.0] + list(range(1, 7)))
Out[81]:
In [80]:
5 * 4 * 3 * 2
Out[80]:
In [83]:
'{0:02.}'.format(2.6)
In [88]:
import dtw
In [109]:
dtw.distance??
In [100]:
A = np.array([1, 2, 4, 6])[:, np.newaxis]
B = np.array([3, 4, 5, 6])[:, np.newaxis]
C = dtw.cost_matrix(A, B)
In [95]:
dtw.cost_matr
In [108]:
np.diagonal(C)
Out[108]:
In [107]:
np.diag(C)
Out[107]:
In [103]:
C
Out[103]:
In [114]:
tol = 1
d_t = np.arange(10)
np.argwhere(np.cumsum(d_t <= tol) != np.arange(1, len(d_t) + 1))[0,0]
Out[114]:
In [115]:
[None] * 0
Out[115]:
In [116]:
np.arange(1, C.shape[0] + 1) + np.arange(1, C.shape[1] + 1)
Out[116]:
In [117]:
np.diag(C) / (np.arange(1, C.shape[0] + 1) + np.arange(1, C.shape[1] + 1))
Out[117]:
In [119]:
1 in [3, 1, 4][:2]
Out[119]:
In [124]:
d_t = np.array([ 0.58333333, 1.777, 2.18738889, 2.24757208, 0.7, 1.55786723])
In [121]:
np.argwhere(np.cumsum(d_t <= tol) != np.arange(1, len(d_t) + 1))[0,0]
Out[121]:
In [122]:
np.argwhere(np.cumsum(d_t <= 0.9) != np.arange(1, len(d_t) + 1))[0,0]
Out[122]:
In [126]:
np.argwhere(d_t <= 0.9)[-1,-1]
Out[126]:
In [133]:
np.linspace(0.01*2, 0.5, 50)
Out[133]:
In [134]:
40 * 50
Out[134]:
In [135]:
hash(np.arange(10.))
In [ ]: