Пример #1
0
from single_evaluation import single_eval
import numpy as np
import csv

x1 = -5
x2 = 5

v, a, t = single_eval('Robin_Pre2', 'pre', 0)

x1_marker = np.where(t >= x1)
x1_marker = x1_marker[0][0]

x2_marker = np.where(t >= x2)
x2_marker = x2_marker[0][0]

iteration = 'optim_in_progress'
data_choice = 'pre'
change_index = 0
h = 0.1

X = np.zeros([len(t[x1_marker:x2_marker]), 234])

for i in range(234):
    V_cPlus = np.ones(234)
    V_cMinus = np.ones(234)

    V_cPlus[i] = V_cPlus[i] + h
    V_cMinus[i] = V_cMinus[i] - h

    with open('./Samples/Temp_optim.csv', 'w') as csv_file:
        csv_writer = csv.writer(csv_file, delimiter=',')
Пример #2
0
#list_of_low_reactions=[4,10,11,12,13,15,17,18,19,22,52,54] # Cube 1
#list_of_low_reactions=[59,58,48,42,4,11]

list_of_low_reactions = [5, 8, 10]

n = len(list_of_low_reactions)
for i in range(2**n):
    b = bin(i)[2:]
    l = len(b)
    b = str(0) * (n - l) + b
    combos.append(b)

numpairs = len(combos)
combos_for_ST = combos.copy()

v_nominal, a_nominal, time = single_eval(values, model, [])
if model == 'pre':
    dataset = 'tots_LNAME_pre'
Data = im.import_Berwick_HET_LNAME_Data(dataset, area='Whisker')

results_v = np.zeros([numpairs, 51])
QoIs = np.zeros([numpairs, 3])
sobolev_norm_R = np.zeros([numpairs, 1])
sobolev_norm_HBR = np.zeros([numpairs, 1])
sobolev_norm_Ca_i = np.zeros([numpairs, 1])

list_removed = list()
for i in range(numpairs):
    print('starting ', i + 1, 'of ', numpairs)

    current_removed_index = list(combos[i])
from numpy.linalg import norm

## Tim these three lines are the ones to edit

reactions_to_remove = [4, 11, 8, 52, 49,
                       50]  # reactions to be removed as a list
xlim1 = -1  #limits /for x values in graph
xlim2 = 20

values = 'Robin_Pre2'
model = 'pre'

norm_flag = 2
v_a_flag = 'v'

v_nominal, a_nominal, t = single_eval(values, model, [])
v = []
a = []

v_temp, a_temp, t = single_eval(values, model, reactions_to_remove)

if model == 'pre':
    dataset = 'tots_LNAME_pre'

    Data = im.import_Berwick_HET_LNAME_Data(dataset, area='Whisker')
    interpolator = interp1d(t, a_temp.HBO_N)
    HBO_interp = interpolator(Data.time)
    Error_HBO = HBO_interp - Data.HbOwhisk_mean
    Error_HBO = sum(map(lambda x: x * x, Error_HBO))

    interpolator = interp1d(t, a_temp.HBR_N)
Пример #4
0
from test_switch_functions import compare_results_v
from test_switch_functions import compare_results_a
from test_switch_functions import compare_results_sobolev

import math
import numpy as np
from numpy.linalg import norm

values = 'Robin_Pre2'
model = 'pre'

norm_flag = 2
v_a_flag = 'sobolev'

v_nominal, a_nominal, time = single_eval(values, model, [])
v = []
a = []

if v_a_flag == 'v':
    for i in range(59 + 1):
        v_temp, a_temp, time = single_eval(values, model, i)
        v.append(v_temp)
        difference = np.zeros([59 + 1, 51])

    for i in range(59 + 1):
        print('%i done' % i)
        difference[i, :] = compare_results_v(v_nominal, v[i], norm_flag)

if v_a_flag == 'a_diff':
    for i in range(59 + 1):