add DATA

parent 10c53e97
C_G:
element_types:
- float64
len: 9
type: list
C_M_times_1_plus_C_T:
element_types:
- float64
len: 9
type: list
H:
element_types:
- float
len: 9
type: list
basis_size:
element_types:
- int
len: 9
max_depth: 1
max_len: 9
total_elements: 9
type: list of lists
error:
element_types:
- float64
len: 9
type: list
estimate:
element_types:
- float64
len: 9
type: list
h:
element_types:
- float
len: 9
max_depth: 1
max_len: 9
total_elements: 9
type: list of lists
num_DoFs:
element_types:
- int
len: 9
type: list
num_elements:
element_types:
- int
len: 9
max_depth: 1
max_len: 9
total_elements: 9
type: list of lists
num_subdomains:
element_types:
- int
len: 9
type: list
num_workers:
element_types:
- int
len: 9
type: list
penalty:
element_types:
- float64
len: 9
type: list
reductor:
element_types:
- str
len: 9
type: list
comment: ''
experiment: test_grid_dependecy_of_Q1_localized_estimate.fixed_H_refined_h
parameters:
domain: !!python/tuple
- - 0
- 0
- - 1
- 1
local_space_type: cg_p1
mu: 1
num_h_refs: 8
num_macro_elements:
- 1
- 1
problem: thermalblock_problem(num_blocks=(1, 1), parameter_range=(0.1, 1))
protected: false
started: 2019-08-27 21:42:11.795102
tags: []
C_G:
element_types:
- float64
len: 8
type: list
C_M_times_1_plus_C_T:
element_types:
- float64
len: 8
type: list
H:
element_types:
- float
len: 8
type: list
basis_size:
element_types:
- int
len: 8
max_depth: 1
max_len: 8
total_elements: 32
type: list of lists
error:
element_types:
- float64
len: 8
type: list
estimate:
element_types:
- float64
len: 8
type: list
h:
element_types:
- float
len: 8
max_depth: 1
max_len: 8
total_elements: 32
type: list of lists
num_DoFs:
element_types:
- int
len: 8
type: list
num_elements:
element_types:
- int
len: 8
max_depth: 1
max_len: 8
total_elements: 32
type: list of lists
num_subdomains:
element_types:
- int
len: 8
type: list
num_workers:
element_types:
- int
len: 8
type: list
penalty:
element_types:
- float64
len: 8
type: list
reductor:
element_types:
- str
len: 8
type: list
comment: ''
experiment: test_grid_dependecy_of_Q1_localized_estimate.fixed_H_refined_h
parameters:
domain: !!python/tuple
- - 0
- 0
- - 1
- 1
local_space_type: cg_p1
mu: 1
num_h_refs: 7
num_macro_elements:
- 2
- 2
problem: thermalblock_problem(num_blocks=(1, 1), parameter_range=(0.1, 1))
protected: false
started: 2019-08-27 21:42:35.690761
tags: []
C_G:
element_types:
- float64
len: 7
type: list
C_M_times_1_plus_C_T:
element_types:
- float64
len: 7
type: list
H:
element_types:
- float
len: 7
type: list
basis_size:
element_types:
- int
len: 7
max_depth: 1
max_len: 16
total_elements: 112
type: list of lists
error:
element_types:
- float64
len: 7
type: list
estimate:
element_types:
- float64
len: 7
type: list
h:
element_types:
- float
len: 7
max_depth: 1
max_len: 16
total_elements: 112
type: list of lists
num_DoFs:
element_types:
- int
len: 7
type: list
num_elements:
element_types:
- int
len: 7
max_depth: 1
max_len: 16
total_elements: 112
type: list of lists
num_subdomains:
element_types:
- int
len: 7
type: list
num_workers:
element_types:
- int
len: 7
type: list
penalty:
element_types:
- float64
len: 7
type: list
reductor:
element_types:
- str
len: 7
type: list
comment: ''
experiment: test_grid_dependecy_of_Q1_localized_estimate.fixed_H_refined_h
parameters:
domain: !!python/tuple
- - 0
- 0
- - 1
- 1
local_space_type: cg_p1
mu: 1
num_h_refs: 6
num_macro_elements:
- 4
- 4
problem: thermalblock_problem(num_blocks=(1, 1), parameter_range=(0.1, 1))
protected: false
started: 2019-08-27 21:42:58.827688
tags: []
C_G:
element_types:
- float64
len: 4
type: list
C_M_times_1_plus_C_T:
element_types:
- float64
len: 4
type: list
H:
element_types:
- float
len: 4
type: list
basis_size:
element_types:
- int
len: 4
max_depth: 1
max_len: 64
total_elements: 85
type: list of lists
error:
element_types:
- float64
len: 4
type: list
estimate:
element_types:
- float64
len: 4
type: list
h:
element_types:
- float
len: 4
max_depth: 1
max_len: 64
total_elements: 85
type: list of lists
num_DoFs:
element_types:
- int
len: 4
type: list
num_elements:
element_types:
- int
len: 4
max_depth: 1
max_len: 64
total_elements: 85
type: list of lists
num_subdomains:
element_types:
- int
len: 4
type: list
num_workers:
element_types:
- int
len: 4
type: list
penalty:
element_types:
- float64
len: 4
type: list
reductor:
element_types:
- str
len: 4
type: list
comment: ''
experiment: test_grid_dependecy_of_Q1_localized_estimate.fixed_h_refined_H
parameters:
domain: !!python/tuple
- - 0
- 0
- - 1
- 1
global_grid_refines: 3
initial_macro_grid:
- 1
- 1
local_space_type: cg_p1
mu: 1
problem: thermalblock_problem(num_blocks=(1, 1), parameter_range=(0.1, 1))
protected: false
started: 2019-08-27 21:43:24.668014
tags: []
This source diff could not be displayed because it is too large. You can view the blob instead.
import yaml
yaml.warnings({'YAMLLoadWarning': False})
import os
import numpy as np
from simdb.run import new_dataset, append_values
from pymor.core.logger import set_log_levels, getLogger
from pymor.operators.block import BlockOperator
from thermalblock_problem import domain, init_problem
from dune.gdt.usercode import DomainDecomposition, ContinuousLagrangePartitionOfUnity
from distributed_elliptic_discretizer import discretize_elliptic_block_swipdg
from distributed_elliptic_reductor import PouLocalizedCoerciveReductor as Reductor
FILENAME = os.path.basename(__file__)[:-3]
set_log_levels({
FILENAME: 'INFO',
'distributed_elliptic_discretizer': 'INFO',
'pymor.discretizations': 'WARN',
})
make_problem = lambda : init_problem((1, 1))
base_config = {
'local_space_type': 'cg_p1',
'domain': domain,
'problem': make_problem()['id'],
'mu': 1,
}
def assert_results(results, expected_results):
errors = {}
for kk, vv in expected_results.items():
if not np.allclose(results[kk], vv):
errors[kk] = {}
errors[kk]['expected'] = vv
errors[kk]['actual'] = results[kk]
assert len(errors) == 0, errors
def compute_on_single_refinemet(cfg, make_pou, pou_id):
logger = getLogger(f'{FILENAME}.compute_on_single_refinemet')
def init_dd():
return DomainDecomposition(cfg['num_macro_elements'],
cfg['num_refinements_per_subdomain'],
domain[0],
domain[1])
dd = init_dd()
p = make_problem()
num_subdomains = dd.num_subdomains
fom = discretize_elliptic_block_swipdg(make_problem, init_dd, cfg['local_space_type'])
fom.globalize() # We need this later on, only here to trigger the output
num_DoFs = fom.solution_space.dim
append_values(num_DoFs=num_DoFs)
logger.info('reducing with initial basis (PoU) ...')
reductor = Reductor(
fom, init_dd, cfg, make_pou=make_pou, kappa_lower=init_problem()['kappa_lower'], pou_id=pou_id)
append_values(reductor=str(reductor))
append_values(basis_size=[len(b) for b in reductor.bases])
rom = reductor.reduce()
logger.info('building error product ...')
product = np.full((dd.num_subdomains, dd.num_subdomains), None)
for (ii, jj), local_prod in fom.products['broken_h1'].items():
product[ii, jj] = local_prod
product = BlockOperator(product)
logger.info('estimating ...')
mu = rom.parse_parameter(cfg['mu'])
u = rom.solve(mu=mu)
estimate = rom.estimate(u, mu=mu)[0]
logger.info('... done (is {})'.format(estimate))
append_values(estimate=estimate)
logger.info('computing error ...')
diff = fom.solve(mu) - reductor.reconstruct(u)
error = np.sqrt(product.apply2(diff, diff))[0][0]
logger.info('... done (is {})'.format(error))
append_values(error=error)
return num_subdomains, num_DoFs, error, estimate
def run_fixed_H_refined_h(
num_h_refs=3,
num_macro_elements=[3, 3],
make_pou=lambda dd: ContinuousLagrangePartitionOfUnity(dd),
pou_id='Q1PoU',
DATASET_ID=FILENAME + '.fixed_H_refined_h'):
config = dict(base_config)
config['num_macro_elements'] = num_macro_elements
config['num_h_refs'] = num_h_refs
new_dataset(DATASET_ID, **config)
results = {'num_subdomains': [], 'num_DoFs': [], 'error': [], 'estimate': []}
for num_refs in np.arange(num_h_refs + 1):
cfg = dict(config)
cfg['num_refinements_per_subdomain'] = num_refs
nsd, nD, er, es = compute_on_single_refinemet(cfg, make_pou, pou_id)
results['num_subdomains'].append(nsd)
results['num_DoFs'].append(nD)
results['error'].append(er)
results['estimate'].append(es)
print('')
return results
def run_fixed_h_refined_H(
global_grid_refines=3,
num_H_refs_less=0,
initial_macro_grid=[1, 1],
make_pou=lambda dd: ContinuousLagrangePartitionOfUnity(dd),
pou_id='Q1PoU',
DATASET_ID=FILENAME + '.fixed_h_refined_H'):
config = dict(base_config)
macro_grid = list(initial_macro_grid)
config['initial_macro_grid'] = initial_macro_grid
config['global_grid_refines'] = global_grid_refines
new_dataset(DATASET_ID, **config)
results = {'num_subdomains': [], 'num_DoFs': [], 'error': [], 'estimate': []}
for _ in np.arange(global_grid_refines - num_H_refs_less + 1):
cfg = dict(config)
cfg['num_macro_elements'] = macro_grid
cfg['num_refinements_per_subdomain'] = global_grid_refines
nsd, nD, er, es = compute_on_single_refinemet(cfg, make_pou, pou_id)
results['num_subdomains'].append(nsd)
results['num_DoFs'].append(nD)
results['error'].append(er)
results['estimate'].append(es)
print('')
global_grid_refines -= 1
macro_grid[0] *= 2
macro_grid[1] *= 2
return results
def expected_results_fixed_H_refined_h(num_h_refs, num_macro_elements):
if num_h_refs == 3 and num_macro_elements == [1, 1]:
return {'num_subdomains': [1, 1, 1, 1],
'num_DoFs': [4, 9, 25, 81],
'error': [2.2827713033690556e-17, 0.17829090592609537, 0.18394776571648075, 0.18812850466547035],
'estimate': [1.379885348450665e-16, 0.7255116728902438, 0.7943998932316314, 0.8043649753996472]}
elif num_h_refs == 3 and num_macro_elements == [3, 3]:
return {'num_subdomains': [9, 9, 9, 9],
'num_DoFs': [36, 81, 225, 729],
'error': [2.437083428529774e-16, 0.06342823397024529, 0.07209377002856301, 0.07411333407007065],
'estimate': [1.2525548119768789e-15, 0.28110033383280547, 0.30527579252513726, 0.3023629356335546]}
else:
assert False, f'missing expected results for num_h_refs={num_h_refs}, num_macro_elements={num_macro_elements}'
def expected_results_fixed_h_refined_H(global_grid_refines, num_H_refs_less, initial_macro_grid):
if global_grid_refines == 3 and num_H_refs_less == 0 and initial_macro_grid == [1, 1]:
return {'num_subdomains': [1, 4, 16, 64],
'num_DoFs': [81, 100, 144, 256],
'error': [0.18812850466547035, 0.10496923582575818, 0.04812058367396117, 1.1495276927521529e-15],
'estimate': [0.8043649753996472, 0.4426426990913186, 0.21654695989615283, 4.156337533325682e-15]}
else:
assert False, f"""missing expected results for global_grid_refines={global_grid_refines},
num_H_refs_less={num_H_refs_less}, initial_macro_grid={initial_macro_grid}"""
def test_fixed_H_refined_h_single_subdomain():
kwargs = {'num_h_refs': 3, 'macro_grid': [1, 1]}
assert_results(run_fixed_H_refined_h(**kwargs), expected_results_fixed_H_refined_h(**kwargs))
def test_fixed_H_refined_h_truely_inner_subdomain():
kwargs = {'num_h_refs': 3, 'macro_grid': [3, 3]}
assert_results(run_fixed_H_refined_h(**kwargs), expected_results_fixed_H_refined_h(**kwargs))
def test_fixed_h_refined_H():
kwargs = {'global_grid_refines': 3, 'num_H_refs_less': 0, 'initial_macro_grid': [1, 1]}
assert_results(run_fixed_h_refined_H(**kwargs), expected_results_fixed_h_refined_H(**kwargs))
if __name__ == '__main__':
run_fixed_H_refined_h(num_h_refs=8, num_macro_elements=[1, 1])
print('')
print('')
run_fixed_H_refined_h(num_h_refs=7, num_macro_elements=[2, 2])