22# Copyright 2013-2018 pyMOR developers and contributors. All rights reserved.
33# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
44
5- from pymor .basic import *
5+ from dealii_elasticity import ElasticityExample
6+ from pymor .basic import (
7+ CoerciveRBReductor ,
8+ ExpressionParameterFunctional ,
9+ LincombOperator ,
10+ ProjectionParameterFunctional ,
11+ StationaryModel ,
12+ VectorOperator ,
13+ rb_greedy ,
14+ reduction_error_analysis ,
15+ )
616
17+ from pymor_dealii .pymor .gui import DealIIVisualizer
718from pymor_dealii .pymor .operator import DealIIMatrixOperator
819from pymor_dealii .pymor .vectorarray import DealIIVectorSpace
9- from pymor_dealii .pymor .gui import DealIIVisualizer
10- from dealii_elasticity import ElasticityExample
1120
1221cpp_disc = ElasticityExample (refine_steps = 7 )
1322
@@ -20,12 +29,12 @@ def run(plot_error=True):
2029 DealIIMatrixOperator (cpp_disc .mu_mat ()),
2130 ],
2231 [
23- ProjectionParameterFunctional (" lambda" ),
24- ProjectionParameterFunctional ("mu" ),
32+ ProjectionParameterFunctional (' lambda' ),
33+ ProjectionParameterFunctional ('mu' ),
2534 ],
2635 ),
2736 rhs = VectorOperator (DealIIVectorSpace .make_array ([cpp_disc .rhs ()])),
28- products = {" energy" : DealIIMatrixOperator (cpp_disc .mu_mat ())},
37+ products = {' energy' : DealIIMatrixOperator (cpp_disc .mu_mat ())},
2938 visualizer = DealIIVisualizer (cpp_disc ),
3039 )
3140 parameter_space = d .parameters .space ((1 , 10 ))
@@ -34,46 +43,46 @@ def run(plot_error=True):
3443 reductor = CoerciveRBReductor (
3544 d ,
3645 product = d .energy_product ,
37- coercivity_estimator = ExpressionParameterFunctional (" max(mu)" , d .parameters ),
46+ coercivity_estimator = ExpressionParameterFunctional (' max(mu)' , d .parameters ),
3847 )
3948
4049 # greedy basis generation
4150 greedy_data = rb_greedy (
4251 d ,
4352 reductor ,
4453 parameter_space .sample_uniformly (3 ),
45- extension_params = {" method" : " gram_schmidt" },
54+ extension_params = {' method' : ' gram_schmidt' },
4655 max_extensions = 5 ,
4756 )
4857
4958 # get reduced order model
50- rd = greedy_data [" rom" ]
59+ rd = greedy_data [' rom' ]
5160
5261 # validate reduced order model
5362 result = reduction_error_analysis (
5463 rd ,
5564 d ,
5665 reductor ,
5766 test_mus = parameter_space .sample_randomly (10 ),
58- basis_sizes = reductor .bases ["RB" ].dim + 1 ,
67+ basis_sizes = reductor .bases ['RB' ].dim + 1 ,
5968 condition = True ,
6069 error_norms = [d .energy_norm ],
6170 plot = plot_error ,
6271 )
6372
6473 # visualize solution for parameter with maximum reduction error
65- mu_max = result [" max_error_mus" ][0 , - 1 ]
74+ mu_max = result [' max_error_mus' ][0 , - 1 ]
6675 U = d .solve (mu_max )
6776 U_rb = reductor .reconstruct (rd .solve (mu_max ))
6877 return result , U , U_rb , d
6978
7079
71- if __name__ == " __main__" :
80+ if __name__ == ' __main__' :
7281 # print/plot results of validation
7382 from matplotlib import pyplot as plt
7483
7584 result , U , U_rb , d = run ()
76- print (result [" summary" ])
85+ print (result [' summary' ])
7786 ERR = U - U_rb
78- d .visualize ([U , U_rb , ERR ], legend = [" fom" , " rom" , " error" ])
87+ d .visualize ([U , U_rb , ERR ], legend = [' fom' , ' rom' , ' error' ])
7988 plt .show ()
0 commit comments