Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • s7603593/dune-microstructure
  • s7603593/dune-microstructure-backup
2 results
Show changes
Showing
with 15859 additions and 0 deletions
## trace generated using paraview version 5.7.0
#
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
case = 1
case = 2
case = 3
#
drawLine = False
curvature = 1
discreteColor = True
gamma = 'infinity'
# gamma = '0'
# gamma = 0.05
# # gamma = 0.25
# gamma = 0.5
# gamma = 0.75
# gamma = 1.0
# gamma = 1.25
# gamma = 1.5
# gamma = 1.5
smallerRegion = False
# create a new 'XML Structured Grid Reader'
# if case == 1:
if gamma == '0':
# phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0_4000P.vts'])
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0.vts'])
# if case == 2:
elif gamma == 'infinity':
# phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_infinity_4000P.vts'])
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_infinity.vts'])
else :
# if case == 3:
smallerRegion = True
if gamma == 0.05:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0.05.vts'])
if gamma == 0.25:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0.25.vts'])
if gamma == 0.5:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0.5.vts'])
if gamma == 0.75:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_0.75.vts'])
if gamma == 1.0:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_1.0.vts'])
if gamma == 1.25:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_1.25.vts'])
if gamma == 1.5:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_1.5.vts'])
phaseDiagram2DGamma_infinity55_4000spvts.CellArrayStatus = []
phaseDiagram2DGamma_infinity55_4000spvts.PointArrayStatus = ['Type', 'angles', 'curvature']
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1380, 547]
# show data in view
phaseDiagram2DGamma_infinity55_4000spvtsDisplay = Show(phaseDiagram2DGamma_infinity55_4000spvts, renderView1)
# get color transfer function/color map for 'Type'
typeLUT = GetColorTransferFunction('Type')
typeLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
typeLUT.InterpretValuesAsCategories = 0
typeLUT.AnnotationsInitialized = 0
typeLUT.ShowCategoricalColorsinDataRangeOnly = 0
typeLUT.RescaleOnVisibilityChange = 0
typeLUT.EnableOpacityMapping = 0
typeLUT.RGBPoints = [1.0, 0.001462, 0.000466, 0.013866, 1.007844, 0.002258, 0.001295, 0.018331, 1.015686, 0.003279, 0.002305, 0.023708, 1.02353, 0.004512, 0.00349, 0.029965, 1.0313720000000002, 0.00595, 0.004843, 0.03713, 1.0392160000000001, 0.007588, 0.006356, 0.044973, 1.0470579999999998, 0.009426, 0.008022, 0.052844, 1.0549019999999998, 0.011465, 0.009828, 0.06075, 1.0627460000000002, 0.013708, 0.011771, 0.068667, 1.0705879999999999, 0.016156, 0.01384, 0.076603, 1.0784319999999998, 0.018815, 0.016026, 0.084584, 1.086274, 0.021692, 0.01832, 0.09261, 1.094118, 0.024792, 0.020715, 0.100676, 1.10196, 0.028123, 0.023201, 0.108787, 1.109804, 0.031696, 0.025765, 0.116965, 1.117648, 0.03552, 0.028397, 0.125209, 1.12549, 0.039608, 0.03109, 0.133515, 1.133334, 0.04383, 0.03383, 0.141886, 1.1411760000000002, 0.048062, 0.036607, 0.150327, 1.1490200000000002, 0.05232, 0.039407, 0.158841, 1.1568619999999998, 0.056615, 0.04216, 0.167446, 1.1647059999999998, 0.060949, 0.044794, 0.176129, 1.1725500000000002, 0.06533, 0.047318, 0.184892, 1.1803919999999999, 0.069764, 0.049726, 0.193735, 1.1882359999999998, 0.074257, 0.052017, 0.20266, 1.196078, 0.078815, 0.054184, 0.211667, 1.203922, 0.083446, 0.056225, 0.220755, 1.211764, 0.088155, 0.058133, 0.229922, 1.219608, 0.092949, 0.059904, 0.239164, 1.2274500000000002, 0.097833, 0.061531, 0.248477, 1.2352940000000001, 0.102815, 0.06301, 0.257854, 1.243138, 0.107899, 0.064335, 0.267289, 1.2509800000000002, 0.113094, 0.065492, 0.276784, 1.2588240000000002, 0.118405, 0.066479, 0.286321, 1.2666659999999998, 0.123833, 0.067295, 0.295879, 1.2745099999999998, 0.12938, 0.067935, 0.305443, 1.282352, 0.135053, 0.068391, 0.315, 1.290196, 0.140858, 0.068654, 0.324538, 1.2980399999999999, 0.146785, 0.068738, 0.334011, 1.305882, 0.152839, 0.068637, 0.343404, 1.313726, 0.159018, 0.068354, 0.352688, 1.321568, 0.165308, 0.067911, 0.361816, 1.329412, 0.171713, 0.067305, 0.370771, 1.3372540000000002, 0.178212, 0.066576, 0.379497, 1.3450980000000001, 0.184801, 0.065732, 0.387973, 1.352942, 0.19146, 0.064818, 0.396152, 1.3607839999999998, 0.198177, 0.063862, 0.404009, 1.3686280000000002, 0.204935, 0.062907, 0.411514, 1.3764699999999999, 0.211718, 0.061992, 0.418647, 1.3843139999999998, 0.218512, 0.061158, 0.425392, 1.392156, 0.225302, 0.060445, 0.431742, 1.4, 0.232077, 0.059889, 0.437695, 1.4078439999999999, 0.238826, 0.059517, 0.443256, 1.415686, 0.245543, 0.059352, 0.448436, 1.42353, 0.25222, 0.059415, 0.453248, 1.431372, 0.258857, 0.059706, 0.45771, 1.439216, 0.265447, 0.060237, 0.46184, 1.4470580000000002, 0.271994, 0.060994, 0.46566, 1.4549020000000001, 0.278493, 0.061978, 0.46919, 1.462746, 0.284951, 0.063168, 0.472451, 1.4705880000000002, 0.291366, 0.064553, 0.475462, 1.4784320000000002, 0.29774, 0.066117, 0.478243, 1.4862739999999999, 0.304081, 0.067835, 0.480812, 1.4941179999999998, 0.310382, 0.069702, 0.483186, 1.50196, 0.316654, 0.07169, 0.48538, 1.509804, 0.322899, 0.073782, 0.487408, 1.5176479999999999, 0.329114, 0.075972, 0.489287, 1.52549, 0.335308, 0.078236, 0.491024, 1.533334, 0.341482, 0.080564, 0.492631, 1.541176, 0.347636, 0.082946, 0.494121, 1.54902, 0.353773, 0.085373, 0.495501, 1.5568619999999997, 0.359898, 0.087831, 0.496778, 1.5647060000000002, 0.366012, 0.090314, 0.49796, 1.5725500000000001, 0.372116, 0.092816, 0.499053, 1.5803919999999998, 0.378211, 0.095332, 0.500067, 1.5882360000000002, 0.384299, 0.097855, 0.501002, 1.5960779999999999, 0.390384, 0.100379, 0.501864, 1.6039219999999998, 0.396467, 0.102902, 0.502658, 1.611764, 0.402548, 0.10542, 0.503386, 1.619608, 0.408629, 0.10793, 0.504052, 1.62745, 0.414709, 0.110431, 0.504662, 1.635294, 0.420791, 0.11292, 0.505215, 1.643138, 0.426877, 0.115395, 0.505714, 1.6509800000000001, 0.432967, 0.117855, 0.50616, 1.658824, 0.439062, 0.120298, 0.506555, 1.6666660000000002, 0.445163, 0.122724, 0.506901, 1.6745100000000002, 0.451271, 0.125132, 0.507198, 1.6823519999999998, 0.457386, 0.127522, 0.507448, 1.6901960000000003, 0.463508, 0.129893, 0.507652, 1.6980399999999998, 0.46964, 0.132245, 0.507809, 1.705882, 0.47578, 0.134577, 0.507921, 1.7137259999999999, 0.481929, 0.136891, 0.507989, 1.721568, 0.488088, 0.139186, 0.508011, 1.729412, 0.494258, 0.141462, 0.507988, 1.737254, 0.500438, 0.143719, 0.50792, 1.745098, 0.506629, 0.145958, 0.507806, 1.752942, 0.512831, 0.148179, 0.507648, 1.7607840000000001, 0.519045, 0.150383, 0.507443, 1.768628, 0.52527, 0.152569, 0.507192, 1.7764699999999998, 0.531507, 0.154739, 0.506895, 1.7843140000000002, 0.537755, 0.156894, 0.506551, 1.7921559999999999, 0.544015, 0.159033, 0.506159, 1.7999999999999998, 0.550287, 0.161158, 0.505719, 1.8078440000000002, 0.556571, 0.163269, 0.50523, 1.815686, 0.562866, 0.165368, 0.504692, 1.8235299999999999, 0.569172, 0.167454, 0.504105, 1.831372, 0.57549, 0.16953, 0.503466, 1.839216, 0.581819, 0.171596, 0.502777, 1.847058, 0.588158, 0.173652, 0.502035, 1.854902, 0.594508, 0.175701, 0.501241, 1.862746, 0.600868, 0.177743, 0.500394, 1.8705880000000001, 0.607238, 0.179779, 0.499492, 1.878432, 0.613617, 0.181811, 0.498536, 1.8862740000000002, 0.620005, 0.18384, 0.497524, 1.8941179999999997, 0.626401, 0.185867, 0.496456, 1.9019599999999999, 0.632805, 0.187893, 0.495332, 1.9098039999999998, 0.639216, 0.189921, 0.49415, 1.9176479999999998, 0.645633, 0.191952, 0.49291, 1.92549, 0.652056, 0.193986, 0.491611, 1.9333339999999999, 0.658483, 0.196027, 0.490253, 1.941176, 0.664915, 0.198075, 0.488836, 1.94902, 0.671349, 0.200133, 0.487358, 1.956862, 0.677786, 0.202203, 0.485819, 1.964706, 0.684224, 0.204286, 0.484219, 1.97255, 0.690661, 0.206384, 0.482558, 1.9803920000000002, 0.697098, 0.208501, 0.480835, 1.9882360000000001, 0.703532, 0.210638, 0.479049, 1.9960779999999998, 0.709962, 0.212797, 0.477201, 2.003922, 0.716387, 0.214982, 0.47529, 2.0117640000000003, 0.722805, 0.217194, 0.473316, 2.019608, 0.729216, 0.219437, 0.471279, 2.02745, 0.735616, 0.221713, 0.46918, 2.035294, 0.742004, 0.224025, 0.467018, 2.043138, 0.748378, 0.226377, 0.464794, 2.05098, 0.754737, 0.228772, 0.462509, 2.058824, 0.761077, 0.231214, 0.460162, 2.0666659999999997, 0.767398, 0.233705, 0.457755, 2.07451, 0.773695, 0.236249, 0.455289, 2.082352, 0.779968, 0.238851, 0.452765, 2.0901959999999997, 0.786212, 0.241514, 0.450184, 2.09804, 0.792427, 0.244242, 0.447543, 2.1058820000000003, 0.798608, 0.24704, 0.444848, 2.1137259999999998, 0.804752, 0.249911, 0.442102, 2.121568, 0.810855, 0.252861, 0.439305, 2.1294120000000003, 0.816914, 0.255895, 0.436461, 2.137254, 0.822926, 0.259016, 0.433573, 2.145098, 0.828886, 0.262229, 0.430644, 2.152942, 0.834791, 0.26554, 0.427671, 2.160784, 0.840636, 0.268953, 0.424666, 2.168628, 0.846416, 0.272473, 0.421631, 2.17647, 0.852126, 0.276106, 0.418573, 2.184314, 0.857763, 0.279857, 0.415496, 2.1921559999999998, 0.86332, 0.283729, 0.412403, 2.2, 0.868793, 0.287728, 0.409303, 2.2078439999999997, 0.874176, 0.291859, 0.406205, 2.215686, 0.879464, 0.296125, 0.403118, 2.2235300000000002, 0.884651, 0.30053, 0.400047, 2.231372, 0.889731, 0.305079, 0.397002, 2.239216, 0.8947, 0.309773, 0.393995, 2.247058, 0.899552, 0.314616, 0.391037, 2.254902, 0.904281, 0.31961, 0.388137, 2.262746, 0.908884, 0.324755, 0.385308, 2.270588, 0.913354, 0.330052, 0.382563, 2.278432, 0.917689, 0.3355, 0.379915, 2.2862739999999997, 0.921884, 0.341098, 0.377376, 2.294118, 0.925937, 0.346844, 0.374959, 2.3019600000000002, 0.929845, 0.352734, 0.372677, 2.3098039999999997, 0.933606, 0.358764, 0.370541, 2.317648, 0.937221, 0.364929, 0.368567, 2.3254900000000003, 0.940687, 0.371224, 0.366762, 2.333334, 0.944006, 0.377643, 0.365136, 2.341176, 0.94718, 0.384178, 0.363701, 2.3490200000000003, 0.95021, 0.39082, 0.362468, 2.356862, 0.953099, 0.397563, 0.361438, 2.364706, 0.955849, 0.4044, 0.360619, 2.37255, 0.958464, 0.411324, 0.360014, 2.380392, 0.960949, 0.418323, 0.35963, 2.388236, 0.96331, 0.42539, 0.359469, 2.396078, 0.965549, 0.432519, 0.359529, 2.4039219999999997, 0.967671, 0.439703, 0.35981, 2.411764, 0.96968, 0.446936, 0.360311, 2.419608, 0.971582, 0.45421, 0.36103, 2.4274500000000003, 0.973381, 0.46152, 0.361965, 2.435294, 0.975082, 0.468861, 0.363111, 2.4431380000000003, 0.97669, 0.476226, 0.364466, 2.45098, 0.97821, 0.483612, 0.366025, 2.458824, 0.979645, 0.491014, 0.367783, 2.466666, 0.981, 0.498428, 0.369734, 2.47451, 0.982279, 0.505851, 0.371874, 2.4823519999999997, 0.983485, 0.51328, 0.374198, 2.490196, 0.984622, 0.520713, 0.376698, 2.49804, 0.985693, 0.528148, 0.379371, 2.5058819999999997, 0.9867, 0.535582, 0.38221, 2.513726, 0.987646, 0.543015, 0.38521, 2.5215680000000003, 0.988533, 0.550446, 0.388365, 2.5294119999999998, 0.989363, 0.557873, 0.391671, 2.537254, 0.990138, 0.565296, 0.395122, 2.5450980000000003, 0.990871, 0.572706, 0.398714, 2.552942, 0.991558, 0.580107, 0.402441, 2.560784, 0.992196, 0.587502, 0.406299, 2.568628, 0.992785, 0.594891, 0.410283, 2.57647, 0.993326, 0.602275, 0.41439, 2.584314, 0.993834, 0.609644, 0.418613, 2.592156, 0.994309, 0.616999, 0.42295, 2.6, 0.994738, 0.62435, 0.427397, 2.607844, 0.995122, 0.631696, 0.431951, 2.615686, 0.99548, 0.639027, 0.436607, 2.6235299999999997, 0.99581, 0.646344, 0.441361, 2.631372, 0.996096, 0.653659, 0.446213, 2.6392160000000002, 0.996341, 0.660969, 0.45116, 2.647058, 0.99658, 0.668256, 0.456192, 2.654902, 0.996775, 0.675541, 0.461314, 2.6627460000000003, 0.996925, 0.682828, 0.466526, 2.670588, 0.997077, 0.690088, 0.471811, 2.678432, 0.997186, 0.697349, 0.477182, 2.686274, 0.997254, 0.704611, 0.482635, 2.694118, 0.997325, 0.711848, 0.488154, 2.7019599999999997, 0.997351, 0.719089, 0.493755, 2.709804, 0.997351, 0.726324, 0.499428, 2.717648, 0.997341, 0.733545, 0.505167, 2.7254899999999997, 0.997285, 0.740772, 0.510983, 2.733334, 0.997228, 0.747981, 0.516859, 2.7411760000000003, 0.997138, 0.75519, 0.522806, 2.74902, 0.997019, 0.762398, 0.528821, 2.756862, 0.996898, 0.769591, 0.534892, 2.7647060000000003, 0.996727, 0.776795, 0.541039, 2.77255, 0.996571, 0.783977, 0.547233, 2.780392, 0.996369, 0.791167, 0.553499, 2.788236, 0.996162, 0.798348, 0.55982, 2.796078, 0.995932, 0.805527, 0.566202, 2.803922, 0.99568, 0.812706, 0.572645, 2.811764, 0.995424, 0.819875, 0.57914, 2.8196079999999997, 0.995131, 0.827052, 0.585701, 2.82745, 0.994851, 0.834213, 0.592307, 2.835294, 0.994524, 0.841387, 0.598983, 2.8431379999999997, 0.994222, 0.84854, 0.605696, 2.85098, 0.993866, 0.855711, 0.612482, 2.8588240000000003, 0.993545, 0.862859, 0.619299, 2.866666, 0.99317, 0.870024, 0.626189, 2.87451, 0.992831, 0.877168, 0.633109, 2.882352, 0.99244, 0.88433, 0.640099, 2.890196, 0.992089, 0.89147, 0.647116, 2.89804, 0.991688, 0.898627, 0.654202, 2.905882, 0.991332, 0.905763, 0.661309, 2.913726, 0.99093, 0.912915, 0.668481, 2.9215679999999997, 0.99057, 0.920049, 0.675675, 2.929412, 0.990175, 0.927196, 0.682926, 2.9372540000000003, 0.989815, 0.934329, 0.690198, 2.9450979999999998, 0.989434, 0.94147, 0.697519, 2.952942, 0.989077, 0.948604, 0.704863, 2.9607840000000003, 0.988717, 0.955742, 0.712242, 2.968628, 0.988367, 0.962878, 0.719649, 2.97647, 0.988033, 0.970012, 0.727077, 2.984314, 0.987691, 0.977154, 0.734536, 2.992156, 0.987387, 0.984288, 0.742002, 3.0, 0.987053, 0.991438, 0.749504]
typeLUT.UseLogScale = 0
typeLUT.ColorSpace = 'RGB'
typeLUT.UseBelowRangeColor = 0
typeLUT.BelowRangeColor = [0.0, 0.0, 0.0]
typeLUT.UseAboveRangeColor = 0
typeLUT.AboveRangeColor = [0.5, 0.5, 0.5]
typeLUT.NanColor = [0.0, 1.0, 0.0]
typeLUT.NanOpacity = 1.0
typeLUT.Discretize = 1
typeLUT.NumberOfTableValues = 256
typeLUT.ScalarRangeInitialized = 1.0
typeLUT.HSVWrap = 0
typeLUT.VectorComponent = 0
typeLUT.VectorMode = 'Magnitude'
typeLUT.AllowDuplicateScalars = 1
typeLUT.Annotations = []
typeLUT.ActiveAnnotatedValues = []
typeLUT.IndexedColors = []
typeLUT.IndexedOpacities = []
# get opacity transfer function/opacity map for 'Type'
typePWF = GetOpacityTransferFunction('Type')
typePWF.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.4276729533762702, 0.625, 0.5, 0.0, 1.7232704162597656, 0.6691176295280457, 0.5, 0.0, 2.3332666599993335, 0.8676470518112183, 0.5, 0.0, 2.471698045730591, 0.6911764740943909, 0.5, 0.0, 3.0, 0.8014705777168274, 0.5, 0.0]
typePWF.AllowDuplicateScalars = 1
typePWF.UseLogScale = 0
typePWF.ScalarRangeInitialized = 1
# trace defaults for the display properties.
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Representation = 'Surface'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.AmbientColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ColorArrayName = ['POINTS', 'Type']
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DiffuseColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.LookupTable = typeLUT
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.MapScalars = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.MultiComponentsMapping = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.InterpolateScalarsBeforeMapping = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Opacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PointSize = 2.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.LineWidth = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.RenderLinesAsTubes = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.RenderPointsAsSpheres = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Interpolation = 'Gouraud'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Specular = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SpecularColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SpecularPower = 100.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Luminosity = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Ambient = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Diffuse = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.EdgeColor = [0.0, 0.0, 0.5]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.BackfaceRepresentation = 'Follow Frontface'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.BackfaceAmbientColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.BackfaceOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Position = [0.0, 0.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Scale = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Orientation = [0.0, 0.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Origin = [0.0, 0.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Pickable = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Texture = None
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Triangulate = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseShaderReplacements = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ShaderReplacements = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.NonlinearSubdivisionLevel = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseDataPartitions = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayUseScaleArray = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayScaleArray = 'Type'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayMaterial = 'None'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Orient = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OrientationMode = 'Direction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectOrientationVectors = 'None'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Scaling = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleMode = 'No Data Scaling Off'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleFactor = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectScaleArray = 'Type'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType = 'Arrow'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseGlyphTable = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphTableIndexArray = 'Type'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseCompositeGlyphTable = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseGlyphCullingAndLOD = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.LODValues = []
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ColorByLODIndex = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GaussianRadius = 0.05
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ShaderPreset = 'Sphere'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.CustomTriangleScale = 3
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.CustomShader = """ // This custom shader code define a gaussian blur
// Please take a look into vtkSMPointGaussianRepresentation.cxx
// for other custom shader examples
//VTK::Color::Impl
float dist2 = dot(offsetVCVSOutput.xy,offsetVCVSOutput.xy);
float gaussian = exp(-0.5*dist2);
opacity = opacity*gaussian;
"""
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.Emissive = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleByArray = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SetScaleArray = ['POINTS', 'Type']
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleArrayComponent = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.UseScaleFunction = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleTransferFunction = 'PiecewiseFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityByArray = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityArray = ['POINTS', 'Type']
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityArrayComponent = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityTransferFunction = 'PiecewiseFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid = 'GridAxesRepresentation'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelColor = [0.0, 1.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelFontSize = 18
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelJustification = 'Left'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionCellLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelColor = [1.0, 1.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelFontSize = 18
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelJustification = 'Left'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectionPointLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes = 'PolarAxesRepresentation'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScalarOpacityFunction = typePWF
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScalarOpacityUnitDistance = 0.03988178566826777
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SelectMapper = 'Projected tetra'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SamplingDimensions = [128, 128, 128]
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OSPRayScaleFunction.UseLogScale = 0
# init the 'Arrow' selected for 'GlyphType'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.TipResolution = 6
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.TipRadius = 0.1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.TipLength = 0.35
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.ShaftResolution = 6
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.ShaftRadius = 0.03
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.GlyphType.Invert = 0
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleTransferFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.4276729533762702, 0.625, 0.5, 0.0, 1.7232704162597656, 0.6691176295280457, 0.5, 0.0, 2.3332666599993335, 0.8676470518112183, 0.5, 0.0, 2.471698045730591, 0.6911764740943909, 0.5, 0.0, 3.0, 0.8014705777168274, 0.5, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.ScaleTransferFunction.UseLogScale = 0
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityTransferFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.4276729533762702, 0.625, 0.5, 0.0, 1.7232704162597656, 0.6691176295280457, 0.5, 0.0, 2.3332666599993335, 0.8676470518112183, 0.5, 0.0, 2.471698045730591, 0.6911764740943909, 0.5, 0.0, 3.0, 0.8014705777168274, 0.5, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.OpacityTransferFunction.UseLogScale = 0
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitle = 'X Axis'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitle = 'Y Axis'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitle = 'Z Axis'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XTitleOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YTitleOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZTitleOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.FacesToRender = 63
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.CullBackface = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.CullFrontface = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.GridColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ShowGrid = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ShowEdges = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ShowTicks = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.LabelUniqueEdgesOnly = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.AxesToLabel = 63
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XAxisNotation = 'Mixed'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XAxisPrecision = 2
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XAxisUseCustomLabels = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.XAxisLabels = []
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YAxisNotation = 'Mixed'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YAxisPrecision = 2
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YAxisUseCustomLabels = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.YAxisLabels = []
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZAxisNotation = 'Mixed'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZAxisPrecision = 2
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZAxisUseCustomLabels = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.ZAxisLabels = []
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.UseCustomBounds = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.DataAxesGrid.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Visibility = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Translation = [0.0, 0.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Scale = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Orientation = [0.0, 0.0, 0.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.EnableCustomBounds = [0, 0, 0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.EnableCustomRange = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.CustomRange = [0.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialAxesVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.DrawRadialGridlines = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarArcsVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.DrawPolarArcsGridlines = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.NumberOfRadialAxes = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.AutoSubdividePolarAxis = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.NumberOfPolarAxis = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.MinimumRadius = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.MinimumAngle = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.MaximumAngle = 90.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialAxesOriginToPolarAxis = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Ratio = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarArcsColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryPolarArcsColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitle = 'Radial Distance'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleLocation = 'Bottom'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarLabelVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarLabelFormat = '%-#6.3g'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarLabelExponentLocation = 'Labels'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialLabelVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialLabelFormat = '%-#3.1f'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialLabelLocation = 'Bottom'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.RadialUnitsVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ScreenSize = 10.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTitleFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisLabelFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTextFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextColor = [1.0, 1.0, 1.0]
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextOpacity = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextFontFamily = 'Arial'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextFontFile = ''
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextBold = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextItalic = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextShadow = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SecondaryRadialAxesTextFontSize = 12
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.EnableDistanceLOD = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.DistanceLODThreshold = 0.7
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.EnableViewAngleLOD = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ViewAngleLODThreshold = 0.7
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.SmallestVisiblePolarAngle = 0.5
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarTicksVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcTicksOriginToPolarAxis = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.TickLocation = 'Both'
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.AxisTickVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.AxisMinorTickVisibility = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcTickVisibility = 1
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcMinorTickVisibility = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.DeltaAngleMajor = 10.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.DeltaAngleMinor = 5.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisMajorTickSize = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTickRatioSize = 0.3
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisMajorTickThickness = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.PolarAxisTickRatioThickness = 0.5
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisMajorTickSize = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTickRatioSize = 0.3
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisMajorTickThickness = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.LastRadialAxisTickRatioThickness = 0.5
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcMajorTickSize = 0.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcTickRatioSize = 0.3
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcMajorTickThickness = 1.0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.ArcTickRatioThickness = 0.5
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.Use2DMode = 0
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.PolarAxes.UseLogAxis = 0
# reset view to fit data
renderView1.ResetCamera()
#changing interaction mode based on data extents
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [0.0, 10010.0, 0.5]
renderView1.CameraFocalPoint = [0.0, 10.0, 0.5]
renderView1.CameraViewUp = [1.0, 0.0, 0.0]
# show color bar/color legend
phaseDiagram2DGamma_infinity55_4000spvtsDisplay.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Transform'
transform1 = Transform(Input=phaseDiagram2DGamma_infinity55_4000spvts)
transform1.Transform = 'Transform'
transform1.TransformAllInputVectors = 1
# init the 'Transform' selected for 'Transform'
transform1.Transform.Translate = [0.0, 0.0, 0.0]
transform1.Transform.Rotate = [0.0, 0.0, 0.0]
transform1.Transform.Scale = [1.0, 1.0, 1.0]
# if case == 3 :
# # Properties modified on transform1.Transform
# transform1.Transform.Scale = [0.0666667, 1.0, 1.0]
# else :
# # Properties modified on transform1.Transform
# transform1.Transform.Scale = [0.1, 1.0, 1.0]
# if gamma == '0' or gamma == 'infinity':
# # Properties modified on transform1.Transform
# transform1.Transform.Scale = [0.1, 1.0, 1.0]
# else :
# # Properties modified on transform1.Transform
# transform1.Transform.Scale = [0.0666667, 1.0, 1.0]
if smallerRegion:
# Properties modified on transform1.Transform
transform1.Transform.Scale = [0.0666667, 1.0, 1.0]
else :
# Properties modified on transform1.Transform
transform1.Transform.Scale = [0.1, 1.0, 1.0]
# show data in view
transform1Display = Show(transform1, renderView1)
# trace defaults for the display properties.
transform1Display.Representation = 'Surface'
transform1Display.AmbientColor = [1.0, 1.0, 1.0]
transform1Display.ColorArrayName = ['POINTS', 'Type']
transform1Display.DiffuseColor = [1.0, 1.0, 1.0]
transform1Display.LookupTable = typeLUT
transform1Display.MapScalars = 1
transform1Display.MultiComponentsMapping = 0
transform1Display.InterpolateScalarsBeforeMapping = 1
transform1Display.Opacity = 1.0
transform1Display.PointSize = 2.0
transform1Display.LineWidth = 1.0
transform1Display.RenderLinesAsTubes = 0
transform1Display.RenderPointsAsSpheres = 0
transform1Display.Interpolation = 'Gouraud'
transform1Display.Specular = 0.0
transform1Display.SpecularColor = [1.0, 1.0, 1.0]
transform1Display.SpecularPower = 100.0
transform1Display.Luminosity = 0.0
transform1Display.Ambient = 0.0
transform1Display.Diffuse = 1.0
transform1Display.EdgeColor = [0.0, 0.0, 0.5]
transform1Display.BackfaceRepresentation = 'Follow Frontface'
transform1Display.BackfaceAmbientColor = [1.0, 1.0, 1.0]
transform1Display.BackfaceDiffuseColor = [1.0, 1.0, 1.0]
transform1Display.BackfaceOpacity = 1.0
transform1Display.Position = [0.0, 0.0, 0.0]
transform1Display.Scale = [1.0, 1.0, 1.0]
transform1Display.Orientation = [0.0, 0.0, 0.0]
transform1Display.Origin = [0.0, 0.0, 0.0]
transform1Display.Pickable = 1
transform1Display.Texture = None
transform1Display.Triangulate = 0
transform1Display.UseShaderReplacements = 0
transform1Display.ShaderReplacements = ''
transform1Display.NonlinearSubdivisionLevel = 1
transform1Display.UseDataPartitions = 0
transform1Display.OSPRayUseScaleArray = 0
transform1Display.OSPRayScaleArray = 'Type'
transform1Display.OSPRayScaleFunction = 'PiecewiseFunction'
transform1Display.OSPRayMaterial = 'None'
transform1Display.Orient = 0
transform1Display.OrientationMode = 'Direction'
transform1Display.SelectOrientationVectors = 'None'
transform1Display.Scaling = 0
transform1Display.ScaleMode = 'No Data Scaling Off'
transform1Display.ScaleFactor = 0.1
transform1Display.SelectScaleArray = 'Type'
transform1Display.GlyphType = 'Arrow'
transform1Display.UseGlyphTable = 0
transform1Display.GlyphTableIndexArray = 'Type'
transform1Display.UseCompositeGlyphTable = 0
transform1Display.UseGlyphCullingAndLOD = 0
transform1Display.LODValues = []
transform1Display.ColorByLODIndex = 0
transform1Display.GaussianRadius = 0.005
transform1Display.ShaderPreset = 'Sphere'
transform1Display.CustomTriangleScale = 3
transform1Display.CustomShader = """ // This custom shader code define a gaussian blur
// Please take a look into vtkSMPointGaussianRepresentation.cxx
// for other custom shader examples
//VTK::Color::Impl
float dist2 = dot(offsetVCVSOutput.xy,offsetVCVSOutput.xy);
float gaussian = exp(-0.5*dist2);
opacity = opacity*gaussian;
"""
transform1Display.Emissive = 0
transform1Display.ScaleByArray = 0
transform1Display.SetScaleArray = ['POINTS', 'Type']
transform1Display.ScaleArrayComponent = ''
transform1Display.UseScaleFunction = 1
transform1Display.ScaleTransferFunction = 'PiecewiseFunction'
transform1Display.OpacityByArray = 0
transform1Display.OpacityArray = ['POINTS', 'Type']
transform1Display.OpacityArrayComponent = ''
transform1Display.OpacityTransferFunction = 'PiecewiseFunction'
transform1Display.DataAxesGrid = 'GridAxesRepresentation'
transform1Display.SelectionCellLabelBold = 0
transform1Display.SelectionCellLabelColor = [0.0, 1.0, 0.0]
transform1Display.SelectionCellLabelFontFamily = 'Arial'
transform1Display.SelectionCellLabelFontFile = ''
transform1Display.SelectionCellLabelFontSize = 18
transform1Display.SelectionCellLabelItalic = 0
transform1Display.SelectionCellLabelJustification = 'Left'
transform1Display.SelectionCellLabelOpacity = 1.0
transform1Display.SelectionCellLabelShadow = 0
transform1Display.SelectionPointLabelBold = 0
transform1Display.SelectionPointLabelColor = [1.0, 1.0, 0.0]
transform1Display.SelectionPointLabelFontFamily = 'Arial'
transform1Display.SelectionPointLabelFontFile = ''
transform1Display.SelectionPointLabelFontSize = 18
transform1Display.SelectionPointLabelItalic = 0
transform1Display.SelectionPointLabelJustification = 'Left'
transform1Display.SelectionPointLabelOpacity = 1.0
transform1Display.SelectionPointLabelShadow = 0
transform1Display.PolarAxes = 'PolarAxesRepresentation'
transform1Display.ScalarOpacityFunction = typePWF
transform1Display.ScalarOpacityUnitDistance = 0.005557396853320044
transform1Display.SelectMapper = 'Projected tetra'
transform1Display.SamplingDimensions = [128, 128, 128]
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
transform1Display.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
transform1Display.OSPRayScaleFunction.UseLogScale = 0
# init the 'Arrow' selected for 'GlyphType'
transform1Display.GlyphType.TipResolution = 6
transform1Display.GlyphType.TipRadius = 0.1
transform1Display.GlyphType.TipLength = 0.35
transform1Display.GlyphType.ShaftResolution = 6
transform1Display.GlyphType.ShaftRadius = 0.03
transform1Display.GlyphType.Invert = 0
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
transform1Display.ScaleTransferFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.4276729533762702, 0.625, 0.5, 0.0, 1.7232704162597656, 0.6691176295280457, 0.5, 0.0, 2.3332666599993335, 0.8676470518112183, 0.5, 0.0, 2.471698045730591, 0.6911764740943909, 0.5, 0.0, 3.0, 0.8014705777168274, 0.5, 0.0]
transform1Display.ScaleTransferFunction.UseLogScale = 0
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
transform1Display.OpacityTransferFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.4276729533762702, 0.625, 0.5, 0.0, 1.7232704162597656, 0.6691176295280457, 0.5, 0.0, 2.3332666599993335, 0.8676470518112183, 0.5, 0.0, 2.471698045730591, 0.6911764740943909, 0.5, 0.0, 3.0, 0.8014705777168274, 0.5, 0.0]
transform1Display.OpacityTransferFunction.UseLogScale = 0
# init the 'GridAxesRepresentation' selected for 'DataAxesGrid'
transform1Display.DataAxesGrid.XTitle = 'X Axis'
transform1Display.DataAxesGrid.YTitle = 'Y Axis'
transform1Display.DataAxesGrid.ZTitle = 'Z Axis'
transform1Display.DataAxesGrid.XTitleColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.XTitleFontFamily = 'Arial'
transform1Display.DataAxesGrid.XTitleFontFile = ''
transform1Display.DataAxesGrid.XTitleBold = 0
transform1Display.DataAxesGrid.XTitleItalic = 0
transform1Display.DataAxesGrid.XTitleFontSize = 12
transform1Display.DataAxesGrid.XTitleShadow = 0
transform1Display.DataAxesGrid.XTitleOpacity = 1.0
transform1Display.DataAxesGrid.YTitleColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.YTitleFontFamily = 'Arial'
transform1Display.DataAxesGrid.YTitleFontFile = ''
transform1Display.DataAxesGrid.YTitleBold = 0
transform1Display.DataAxesGrid.YTitleItalic = 0
transform1Display.DataAxesGrid.YTitleFontSize = 12
transform1Display.DataAxesGrid.YTitleShadow = 0
transform1Display.DataAxesGrid.YTitleOpacity = 1.0
transform1Display.DataAxesGrid.ZTitleColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.ZTitleFontFamily = 'Arial'
transform1Display.DataAxesGrid.ZTitleFontFile = ''
transform1Display.DataAxesGrid.ZTitleBold = 0
transform1Display.DataAxesGrid.ZTitleItalic = 0
transform1Display.DataAxesGrid.ZTitleFontSize = 12
transform1Display.DataAxesGrid.ZTitleShadow = 0
transform1Display.DataAxesGrid.ZTitleOpacity = 1.0
transform1Display.DataAxesGrid.FacesToRender = 63
transform1Display.DataAxesGrid.CullBackface = 0
transform1Display.DataAxesGrid.CullFrontface = 1
transform1Display.DataAxesGrid.GridColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.ShowGrid = 0
transform1Display.DataAxesGrid.ShowEdges = 1
transform1Display.DataAxesGrid.ShowTicks = 1
transform1Display.DataAxesGrid.LabelUniqueEdgesOnly = 1
transform1Display.DataAxesGrid.AxesToLabel = 63
transform1Display.DataAxesGrid.XLabelColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.XLabelFontFamily = 'Arial'
transform1Display.DataAxesGrid.XLabelFontFile = ''
transform1Display.DataAxesGrid.XLabelBold = 0
transform1Display.DataAxesGrid.XLabelItalic = 0
transform1Display.DataAxesGrid.XLabelFontSize = 12
transform1Display.DataAxesGrid.XLabelShadow = 0
transform1Display.DataAxesGrid.XLabelOpacity = 1.0
transform1Display.DataAxesGrid.YLabelColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.YLabelFontFamily = 'Arial'
transform1Display.DataAxesGrid.YLabelFontFile = ''
transform1Display.DataAxesGrid.YLabelBold = 0
transform1Display.DataAxesGrid.YLabelItalic = 0
transform1Display.DataAxesGrid.YLabelFontSize = 12
transform1Display.DataAxesGrid.YLabelShadow = 0
transform1Display.DataAxesGrid.YLabelOpacity = 1.0
transform1Display.DataAxesGrid.ZLabelColor = [1.0, 1.0, 1.0]
transform1Display.DataAxesGrid.ZLabelFontFamily = 'Arial'
transform1Display.DataAxesGrid.ZLabelFontFile = ''
transform1Display.DataAxesGrid.ZLabelBold = 0
transform1Display.DataAxesGrid.ZLabelItalic = 0
transform1Display.DataAxesGrid.ZLabelFontSize = 12
transform1Display.DataAxesGrid.ZLabelShadow = 0
transform1Display.DataAxesGrid.ZLabelOpacity = 1.0
transform1Display.DataAxesGrid.XAxisNotation = 'Mixed'
transform1Display.DataAxesGrid.XAxisPrecision = 2
transform1Display.DataAxesGrid.XAxisUseCustomLabels = 0
transform1Display.DataAxesGrid.XAxisLabels = []
transform1Display.DataAxesGrid.YAxisNotation = 'Mixed'
transform1Display.DataAxesGrid.YAxisPrecision = 2
transform1Display.DataAxesGrid.YAxisUseCustomLabels = 0
transform1Display.DataAxesGrid.YAxisLabels = []
transform1Display.DataAxesGrid.ZAxisNotation = 'Mixed'
transform1Display.DataAxesGrid.ZAxisPrecision = 2
transform1Display.DataAxesGrid.ZAxisUseCustomLabels = 0
transform1Display.DataAxesGrid.ZAxisLabels = []
transform1Display.DataAxesGrid.UseCustomBounds = 0
transform1Display.DataAxesGrid.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
# init the 'PolarAxesRepresentation' selected for 'PolarAxes'
transform1Display.PolarAxes.Visibility = 0
transform1Display.PolarAxes.Translation = [0.0, 0.0, 0.0]
transform1Display.PolarAxes.Scale = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.Orientation = [0.0, 0.0, 0.0]
transform1Display.PolarAxes.EnableCustomBounds = [0, 0, 0]
transform1Display.PolarAxes.CustomBounds = [0.0, 1.0, 0.0, 1.0, 0.0, 1.0]
transform1Display.PolarAxes.EnableCustomRange = 0
transform1Display.PolarAxes.CustomRange = [0.0, 1.0]
transform1Display.PolarAxes.PolarAxisVisibility = 1
transform1Display.PolarAxes.RadialAxesVisibility = 1
transform1Display.PolarAxes.DrawRadialGridlines = 1
transform1Display.PolarAxes.PolarArcsVisibility = 1
transform1Display.PolarAxes.DrawPolarArcsGridlines = 1
transform1Display.PolarAxes.NumberOfRadialAxes = 0
transform1Display.PolarAxes.AutoSubdividePolarAxis = 1
transform1Display.PolarAxes.NumberOfPolarAxis = 0
transform1Display.PolarAxes.MinimumRadius = 0.0
transform1Display.PolarAxes.MinimumAngle = 0.0
transform1Display.PolarAxes.MaximumAngle = 90.0
transform1Display.PolarAxes.RadialAxesOriginToPolarAxis = 1
transform1Display.PolarAxes.Ratio = 1.0
transform1Display.PolarAxes.PolarAxisColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.PolarArcsColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.LastRadialAxisColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.SecondaryPolarArcsColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.SecondaryRadialAxesColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.PolarAxisTitleVisibility = 1
transform1Display.PolarAxes.PolarAxisTitle = 'Radial Distance'
transform1Display.PolarAxes.PolarAxisTitleLocation = 'Bottom'
transform1Display.PolarAxes.PolarLabelVisibility = 1
transform1Display.PolarAxes.PolarLabelFormat = '%-#6.3g'
transform1Display.PolarAxes.PolarLabelExponentLocation = 'Labels'
transform1Display.PolarAxes.RadialLabelVisibility = 1
transform1Display.PolarAxes.RadialLabelFormat = '%-#3.1f'
transform1Display.PolarAxes.RadialLabelLocation = 'Bottom'
transform1Display.PolarAxes.RadialUnitsVisibility = 1
transform1Display.PolarAxes.ScreenSize = 10.0
transform1Display.PolarAxes.PolarAxisTitleColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.PolarAxisTitleOpacity = 1.0
transform1Display.PolarAxes.PolarAxisTitleFontFamily = 'Arial'
transform1Display.PolarAxes.PolarAxisTitleFontFile = ''
transform1Display.PolarAxes.PolarAxisTitleBold = 0
transform1Display.PolarAxes.PolarAxisTitleItalic = 0
transform1Display.PolarAxes.PolarAxisTitleShadow = 0
transform1Display.PolarAxes.PolarAxisTitleFontSize = 12
transform1Display.PolarAxes.PolarAxisLabelColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.PolarAxisLabelOpacity = 1.0
transform1Display.PolarAxes.PolarAxisLabelFontFamily = 'Arial'
transform1Display.PolarAxes.PolarAxisLabelFontFile = ''
transform1Display.PolarAxes.PolarAxisLabelBold = 0
transform1Display.PolarAxes.PolarAxisLabelItalic = 0
transform1Display.PolarAxes.PolarAxisLabelShadow = 0
transform1Display.PolarAxes.PolarAxisLabelFontSize = 12
transform1Display.PolarAxes.LastRadialAxisTextColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.LastRadialAxisTextOpacity = 1.0
transform1Display.PolarAxes.LastRadialAxisTextFontFamily = 'Arial'
transform1Display.PolarAxes.LastRadialAxisTextFontFile = ''
transform1Display.PolarAxes.LastRadialAxisTextBold = 0
transform1Display.PolarAxes.LastRadialAxisTextItalic = 0
transform1Display.PolarAxes.LastRadialAxisTextShadow = 0
transform1Display.PolarAxes.LastRadialAxisTextFontSize = 12
transform1Display.PolarAxes.SecondaryRadialAxesTextColor = [1.0, 1.0, 1.0]
transform1Display.PolarAxes.SecondaryRadialAxesTextOpacity = 1.0
transform1Display.PolarAxes.SecondaryRadialAxesTextFontFamily = 'Arial'
transform1Display.PolarAxes.SecondaryRadialAxesTextFontFile = ''
transform1Display.PolarAxes.SecondaryRadialAxesTextBold = 0
transform1Display.PolarAxes.SecondaryRadialAxesTextItalic = 0
transform1Display.PolarAxes.SecondaryRadialAxesTextShadow = 0
transform1Display.PolarAxes.SecondaryRadialAxesTextFontSize = 12
transform1Display.PolarAxes.EnableDistanceLOD = 1
transform1Display.PolarAxes.DistanceLODThreshold = 0.7
transform1Display.PolarAxes.EnableViewAngleLOD = 1
transform1Display.PolarAxes.ViewAngleLODThreshold = 0.7
transform1Display.PolarAxes.SmallestVisiblePolarAngle = 0.5
transform1Display.PolarAxes.PolarTicksVisibility = 1
transform1Display.PolarAxes.ArcTicksOriginToPolarAxis = 1
transform1Display.PolarAxes.TickLocation = 'Both'
transform1Display.PolarAxes.AxisTickVisibility = 1
transform1Display.PolarAxes.AxisMinorTickVisibility = 0
transform1Display.PolarAxes.ArcTickVisibility = 1
transform1Display.PolarAxes.ArcMinorTickVisibility = 0
transform1Display.PolarAxes.DeltaAngleMajor = 10.0
transform1Display.PolarAxes.DeltaAngleMinor = 5.0
transform1Display.PolarAxes.PolarAxisMajorTickSize = 0.0
transform1Display.PolarAxes.PolarAxisTickRatioSize = 0.3
transform1Display.PolarAxes.PolarAxisMajorTickThickness = 1.0
transform1Display.PolarAxes.PolarAxisTickRatioThickness = 0.5
transform1Display.PolarAxes.LastRadialAxisMajorTickSize = 0.0
transform1Display.PolarAxes.LastRadialAxisTickRatioSize = 0.3
transform1Display.PolarAxes.LastRadialAxisMajorTickThickness = 1.0
transform1Display.PolarAxes.LastRadialAxisTickRatioThickness = 0.5
transform1Display.PolarAxes.ArcMajorTickSize = 0.0
transform1Display.PolarAxes.ArcTickRatioSize = 0.3
transform1Display.PolarAxes.ArcMajorTickThickness = 1.0
transform1Display.PolarAxes.ArcTickRatioThickness = 0.5
transform1Display.PolarAxes.Use2DMode = 0
transform1Display.PolarAxes.UseLogAxis = 0
# hide data in view
Hide(phaseDiagram2DGamma_infinity55_4000spvts, renderView1)
# ----------------- DRAW LINE -----------------
# # create a new 'Line'
# line1 = Line()
#
# # show data in view
# line1Display = Show(line1, renderView1)
# # set active source
# SetActiveSource(line1)
#
# # Properties modified on line1
# line1.Point1 = [0.3, 0.0, 0.0]
# line1.Point2 = [0.3, 0.0, 1.0]
#
# # Properties modified on line1Display
# # line1Display.LineWidth = 2.0
# line1Display.LineWidth = 4.0
#
# # change solid color
# line1Display.AmbientColor = [1.0, 1.0, 0.4980392156862745]
# line1Display.DiffuseColor = [1.0, 1.0, 0.4980392156862745]
#
# # toggle 3D widget visibility (only when running from the GUI)
# Show3DWidgets(proxy=line1)
#
# # update the view to ensure updated data information
# renderView1.Update()
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=transform1.Transform)
# reset view to fit data
renderView1.ResetCamera()
# change representation type
transform1Display.SetRepresentationType('Point Gaussian')
# Properties modified on transform1Display
transform1Display.ShaderPreset = 'Plain circle'
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'angles'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(typeLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
transform1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'angles'
anglesLUT = GetColorTransferFunction('angles')
anglesLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
anglesLUT.InterpretValuesAsCategories = 0
anglesLUT.AnnotationsInitialized = 0
anglesLUT.ShowCategoricalColorsinDataRangeOnly = 0
anglesLUT.RescaleOnVisibilityChange = 0
anglesLUT.EnableOpacityMapping = 0
anglesLUT.RGBPoints = [0.0, 0.001462, 0.000466, 0.013866, 0.006160663193689554, 0.002258, 0.001295, 0.018331, 0.012319755591052443, 0.003279, 0.002305, 0.023708, 0.018480418784742, 0.004512, 0.00349, 0.029965, 0.024639511182104886, 0.00595, 0.004843, 0.03713, 0.03080017437579444, 0.007588, 0.006356, 0.044973, 0.03695926677315698, 0.009426, 0.008022, 0.052844, 0.043119929966846535, 0.011465, 0.009828, 0.06075, 0.04928059316053644, 0.013708, 0.011771, 0.068667, 0.05543968555789898, 0.016156, 0.01384, 0.076603, 0.061600348751588534, 0.018815, 0.016026, 0.084584, 0.06775944114895142, 0.021692, 0.01832, 0.09261, 0.07392010434264097, 0.024792, 0.020715, 0.100676, 0.08007919674000387, 0.028123, 0.023201, 0.108787, 0.08623985993369342, 0.031696, 0.025765, 0.116965, 0.09240052312738298, 0.03552, 0.028397, 0.125209, 0.09855961552474586, 0.039608, 0.03109, 0.133515, 0.10472027871843542, 0.04383, 0.03383, 0.141886, 0.1108793711157983, 0.048062, 0.036607, 0.150327, 0.11704003430948787, 0.05232, 0.039407, 0.158841, 0.1231991267068504, 0.056615, 0.04216, 0.167446, 0.12935978990053995, 0.060949, 0.044794, 0.176129, 0.13552045309422986, 0.06533, 0.047318, 0.184892, 0.1416795454915924, 0.069764, 0.049726, 0.193735, 0.14784020868528194, 0.074257, 0.052017, 0.20266, 0.15399930108264484, 0.078815, 0.054184, 0.211667, 0.1601599642763344, 0.083446, 0.056225, 0.220755, 0.16631905667369729, 0.088155, 0.058133, 0.229922, 0.17247971986738683, 0.092949, 0.059904, 0.239164, 0.17863881226474973, 0.097833, 0.061531, 0.248477, 0.18479947545843928, 0.102815, 0.06301, 0.257854, 0.19096013865212885, 0.107899, 0.064335, 0.267289, 0.19711923104949172, 0.113094, 0.065492, 0.276784, 0.20327989424318127, 0.118405, 0.066479, 0.286321, 0.20943898664054383, 0.123833, 0.067295, 0.295879, 0.21559964983423338, 0.12938, 0.067935, 0.305443, 0.22175874223159628, 0.135053, 0.068391, 0.315, 0.22791940542528583, 0.140858, 0.068654, 0.324538, 0.23408006861897537, 0.146785, 0.068738, 0.334011, 0.24023916101633827, 0.152839, 0.068637, 0.343404, 0.24639982421002782, 0.159018, 0.068354, 0.352688, 0.2525589166073907, 0.165308, 0.067911, 0.361816, 0.25871957980108024, 0.171713, 0.067305, 0.370771, 0.26487867219844313, 0.178212, 0.066576, 0.379497, 0.2710393353921327, 0.184801, 0.065732, 0.387973, 0.2771999985858223, 0.19146, 0.064818, 0.396152, 0.2833590909831848, 0.198177, 0.063862, 0.404009, 0.2895197541768747, 0.204935, 0.062907, 0.411514, 0.29567884657423726, 0.211718, 0.061992, 0.418647, 0.3018395097679268, 0.218512, 0.061158, 0.425392, 0.3079986021652897, 0.225302, 0.060445, 0.431742, 0.31415926535897926, 0.232077, 0.059889, 0.437695, 0.3203199285526688, 0.238826, 0.059517, 0.443256, 0.3264790209500317, 0.245543, 0.059352, 0.448436, 0.33263968414372125, 0.25222, 0.059415, 0.453248, 0.33879877654108415, 0.258857, 0.059706, 0.45771, 0.34495943973477367, 0.265447, 0.060237, 0.46184, 0.35111853213213656, 0.271994, 0.060994, 0.46566, 0.35727919532582614, 0.278493, 0.061978, 0.46919, 0.36343985851951566, 0.284951, 0.063168, 0.472451, 0.36959895091687855, 0.291366, 0.064553, 0.475462, 0.37575961411056813, 0.29774, 0.066117, 0.478243, 0.38191870650793064, 0.304081, 0.067835, 0.480812, 0.3880793697016202, 0.310382, 0.069702, 0.483186, 0.3942384620989831, 0.316654, 0.07169, 0.48538, 0.4003991252926727, 0.322899, 0.073782, 0.487408, 0.4065597884863622, 0.329114, 0.075972, 0.489287, 0.4127188808837251, 0.335308, 0.078236, 0.491024, 0.4188795440774147, 0.341482, 0.080564, 0.492631, 0.4250386364747776, 0.347636, 0.082946, 0.494121, 0.4311992996684671, 0.353773, 0.085373, 0.495501, 0.43735839206582966, 0.359898, 0.087831, 0.496778, 0.44351905525951957, 0.366012, 0.090314, 0.49796, 0.4496797184532091, 0.372116, 0.092816, 0.499053, 0.45583881085057165, 0.378211, 0.095332, 0.500067, 0.46199947404426156, 0.384299, 0.097855, 0.501002, 0.46815856644162407, 0.390384, 0.100379, 0.501864, 0.47431922963531364, 0.396467, 0.102902, 0.502658, 0.48047832203267654, 0.402548, 0.10542, 0.503386, 0.48663898522636606, 0.408629, 0.10793, 0.504052, 0.49279807762372896, 0.414709, 0.110431, 0.504662, 0.49895874081741853, 0.420791, 0.11292, 0.505215, 0.5051194040111081, 0.426877, 0.115395, 0.505714, 0.511278496408471, 0.432967, 0.117855, 0.50616, 0.5174391596021605, 0.439062, 0.120298, 0.506555, 0.5235982519995234, 0.445163, 0.122724, 0.506901, 0.5297589151932129, 0.451271, 0.125132, 0.507198, 0.5359180075905755, 0.457386, 0.127522, 0.507448, 0.5420786707842654, 0.463508, 0.129893, 0.507652, 0.5482393339779547, 0.46964, 0.132245, 0.507809, 0.5543984263753176, 0.47578, 0.134577, 0.507921, 0.560559089569007, 0.481929, 0.136891, 0.507989, 0.5667181819663699, 0.488088, 0.139186, 0.508011, 0.5728788451600595, 0.494258, 0.141462, 0.507988, 0.5790379375574224, 0.500438, 0.143719, 0.50792, 0.585198600751112, 0.506629, 0.145958, 0.507806, 0.5913592639448015, 0.512831, 0.148179, 0.507648, 0.5975183563421644, 0.519045, 0.150383, 0.507443, 0.6036790195358539, 0.52527, 0.152569, 0.507192, 0.6098381119332165, 0.531507, 0.154739, 0.506895, 0.6159987751269064, 0.537755, 0.156894, 0.506551, 0.6221578675242689, 0.544015, 0.159033, 0.506159, 0.6283185307179585, 0.550287, 0.161158, 0.505719, 0.6344791939116484, 0.556571, 0.163269, 0.50523, 0.6406382863090109, 0.562866, 0.165368, 0.504692, 0.6467989495027004, 0.569172, 0.167454, 0.504105, 0.6529580419000633, 0.57549, 0.16953, 0.503466, 0.6591187050937529, 0.581819, 0.171596, 0.502777, 0.6652777974911158, 0.588158, 0.173652, 0.502035, 0.6714384606848054, 0.594508, 0.175701, 0.501241, 0.677599123878495, 0.600868, 0.177743, 0.500394, 0.6837582162758579, 0.607238, 0.179779, 0.499492, 0.6899188794695473, 0.613617, 0.181811, 0.498536, 0.6960779718669102, 0.620005, 0.18384, 0.497524, 0.7022386350605995, 0.626401, 0.185867, 0.496456, 0.7083977274579624, 0.632805, 0.187893, 0.495332, 0.7145583906516519, 0.639216, 0.189921, 0.49415, 0.7207190538453414, 0.645633, 0.191952, 0.49291, 0.7268781462427043, 0.652056, 0.193986, 0.491611, 0.7330388094363939, 0.658483, 0.196027, 0.490253, 0.7391979018337568, 0.664915, 0.198075, 0.488836, 0.7453585650274464, 0.671349, 0.200133, 0.487358, 0.7515176574248092, 0.677786, 0.202203, 0.485819, 0.7576783206184988, 0.684224, 0.204286, 0.484219, 0.7638389838121884, 0.690661, 0.206384, 0.482558, 0.7699980762095512, 0.697098, 0.208501, 0.480835, 0.7761587394032408, 0.703532, 0.210638, 0.479049, 0.7823178318006033, 0.709962, 0.212797, 0.477201, 0.7884784949942932, 0.716387, 0.214982, 0.47529, 0.7946375873916561, 0.722805, 0.217194, 0.473316, 0.8007982505853454, 0.729216, 0.219437, 0.471279, 0.8069573429827082, 0.735616, 0.221713, 0.46918, 0.8131180061763977, 0.742004, 0.224025, 0.467018, 0.8192786693700873, 0.748378, 0.226377, 0.464794, 0.8254377617674502, 0.754737, 0.228772, 0.462509, 0.8315984249611398, 0.761077, 0.231214, 0.460162, 0.8377575173585023, 0.767398, 0.233705, 0.457755, 0.8439181805521923, 0.773695, 0.236249, 0.455289, 0.8500772729495552, 0.779968, 0.238851, 0.452765, 0.8562379361432443, 0.786212, 0.241514, 0.450184, 0.8623985993369342, 0.792427, 0.244242, 0.447543, 0.8685576917342971, 0.798608, 0.24704, 0.444848, 0.8747183549279863, 0.804752, 0.249911, 0.442102, 0.8808774473253492, 0.810855, 0.252861, 0.439305, 0.8870381105190391, 0.816914, 0.255895, 0.436461, 0.8931972029164016, 0.822926, 0.259016, 0.433573, 0.8993578661100912, 0.828886, 0.262229, 0.430644, 0.9055185293037807, 0.834791, 0.26554, 0.427671, 0.9116776217011436, 0.840636, 0.268953, 0.424666, 0.9178382848948332, 0.846416, 0.272473, 0.421631, 0.9239973772921961, 0.852126, 0.276106, 0.418573, 0.9301580404858857, 0.857763, 0.279857, 0.415496, 0.9363171328832481, 0.86332, 0.283729, 0.412403, 0.942477796076938, 0.868793, 0.287728, 0.409303, 0.9486384592706273, 0.874176, 0.291859, 0.406205, 0.9547975516679902, 0.879464, 0.296125, 0.403118, 0.9609582148616801, 0.884651, 0.30053, 0.400047, 0.9671173072590427, 0.889731, 0.305079, 0.397002, 0.9732779704527321, 0.8947, 0.309773, 0.393995, 0.979437062850095, 0.899552, 0.314616, 0.391037, 0.9855977260437846, 0.904281, 0.31961, 0.388137, 0.9917583892374742, 0.908884, 0.324755, 0.385308, 0.9979174816348371, 0.913354, 0.330052, 0.382563, 1.0040781448285265, 0.917689, 0.3355, 0.379915, 1.0102372372258892, 0.921884, 0.341098, 0.377376, 1.0163979004195791, 0.925937, 0.346844, 0.374959, 1.022556992816942, 0.929845, 0.352734, 0.372677, 1.0287176560106313, 0.933606, 0.358764, 0.370541, 1.034878319204321, 0.937221, 0.364929, 0.368567, 1.0410374116016838, 0.940687, 0.371224, 0.366762, 1.047198074795373, 0.944006, 0.377643, 0.365136, 1.053357167192736, 0.94718, 0.384178, 0.363701, 1.0595178303864259, 0.95021, 0.39082, 0.362468, 1.0656769227837886, 0.953099, 0.397563, 0.361438, 1.071837585977478, 0.955849, 0.4044, 0.360619, 1.0779982491711675, 0.958464, 0.411324, 0.360014, 1.0841573415685304, 0.960949, 0.418323, 0.35963, 1.09031800476222, 0.96331, 0.42539, 0.359469, 1.096477097159583, 0.965549, 0.432519, 0.359529, 1.1026377603532722, 0.967671, 0.439703, 0.35981, 1.108796852750635, 0.96968, 0.446936, 0.360311, 1.114957515944325, 0.971582, 0.45421, 0.36103, 1.121116608341688, 0.973381, 0.46152, 0.361965, 1.127277271535377, 0.975082, 0.468861, 0.363111, 1.1334379347290668, 0.97669, 0.476226, 0.364466, 1.1395970271264295, 0.97821, 0.483612, 0.366025, 1.145757690320119, 0.979645, 0.491014, 0.367783, 1.1519167827174819, 0.981, 0.498428, 0.369734, 1.1580774459111713, 0.982279, 0.505851, 0.371874, 1.164236538308534, 0.983485, 0.51328, 0.374198, 1.170397201502224, 0.984622, 0.520713, 0.376698, 1.1765578646959134, 0.985693, 0.528148, 0.379371, 1.182716957093276, 0.9867, 0.535582, 0.38221, 1.188877620286966, 0.987646, 0.543015, 0.38521, 1.1950367126843289, 0.988533, 0.550446, 0.388365, 1.201197375878018, 0.989363, 0.557873, 0.391671, 1.2073564682753808, 0.990138, 0.565296, 0.395122, 1.2135171314690707, 0.990871, 0.572706, 0.398714, 1.21967779466276, 0.991558, 0.580107, 0.402441, 1.2258368870601228, 0.992196, 0.587502, 0.406299, 1.2319975502538125, 0.992785, 0.594891, 0.410283, 1.2381566426511754, 0.993326, 0.602275, 0.41439, 1.2443173058448649, 0.993834, 0.609644, 0.418613, 1.2504763982422278, 0.994309, 0.616999, 0.42295, 1.2566370614359172, 0.994738, 0.62435, 0.427397, 1.262797724629607, 0.995122, 0.631696, 0.431951, 1.2689568170269698, 0.99548, 0.639027, 0.436607, 1.275117480220659, 0.99581, 0.646344, 0.441361, 1.2812765726180217, 0.996096, 0.653659, 0.446213, 1.2874372358117117, 0.996341, 0.660969, 0.45116, 1.2935963282090743, 0.99658, 0.668256, 0.456192, 1.2997569914027638, 0.996775, 0.675541, 0.461314, 1.3059176545964537, 0.996925, 0.682828, 0.466526, 1.3120767469938164, 0.997077, 0.690088, 0.471811, 1.3182374101875058, 0.997186, 0.697349, 0.477182, 1.3243965025848687, 0.997254, 0.704611, 0.482635, 1.3305571657785582, 0.997325, 0.711848, 0.488154, 1.3367162581759209, 0.997351, 0.719089, 0.493755, 1.3428769213696108, 0.997351, 0.726324, 0.499428, 1.3490375845633003, 0.997341, 0.733545, 0.505167, 1.355196676960663, 0.997285, 0.740772, 0.510983, 1.3613573401543528, 0.997228, 0.747981, 0.516859, 1.3675164325517157, 0.997138, 0.75519, 0.522806, 1.3736770957454048, 0.997019, 0.762398, 0.528821, 1.3798361881427677, 0.996898, 0.769591, 0.534892, 1.3859968513364576, 0.996727, 0.776795, 0.541039, 1.3921575145301468, 0.996571, 0.783977, 0.547233, 1.3983166069275097, 0.996369, 0.791167, 0.553499, 1.4044772701211992, 0.996162, 0.798348, 0.55982, 1.410636362518562, 0.995932, 0.805527, 0.566202, 1.4167970257122517, 0.99568, 0.812706, 0.572645, 1.4229561181096146, 0.995424, 0.819875, 0.57914, 1.4291167813033039, 0.995131, 0.827052, 0.585701, 1.4352758737006668, 0.994851, 0.834213, 0.592307, 1.4414365368943567, 0.994524, 0.841387, 0.598983, 1.4475972000880457, 0.994222, 0.84854, 0.605696, 1.4537562924854086, 0.993866, 0.855711, 0.612482, 1.4599169556790985, 0.993545, 0.862859, 0.619299, 1.4660760480764612, 0.99317, 0.870024, 0.626189, 1.4722367112701507, 0.992831, 0.877168, 0.633109, 1.4783958036675136, 0.99244, 0.88433, 0.640099, 1.4845564668612032, 0.992089, 0.89147, 0.647116, 1.4907171300548927, 0.991688, 0.898627, 0.654202, 1.4968762224522556, 0.991332, 0.905763, 0.661309, 1.503036885645945, 0.99093, 0.912915, 0.668481, 1.5091959780433077, 0.99057, 0.920049, 0.675675, 1.5153566412369976, 0.990175, 0.927196, 0.682926, 1.5215157336343605, 0.989815, 0.934329, 0.690198, 1.5276763968280496, 0.989434, 0.94147, 0.697519, 1.5338370600217395, 0.989077, 0.948604, 0.704863, 1.5399961524191024, 0.988717, 0.955742, 0.712242, 1.5461568156127916, 0.988367, 0.962878, 0.719649, 1.5523159080101545, 0.988033, 0.970012, 0.727077, 1.5584765712038442, 0.987691, 0.977154, 0.734536, 1.564635663601207, 0.987387, 0.984288, 0.742002, 1.5707963267948966, 0.987053, 0.991438, 0.749504]
anglesLUT.UseLogScale = 0
anglesLUT.ColorSpace = 'RGB'
anglesLUT.UseBelowRangeColor = 0
anglesLUT.BelowRangeColor = [0.0, 0.0, 0.0]
anglesLUT.UseAboveRangeColor = 0
anglesLUT.AboveRangeColor = [0.5, 0.5, 0.5]
anglesLUT.NanColor = [0.0, 1.0, 0.0]
anglesLUT.NanOpacity = 1.0
anglesLUT.Discretize = 1
anglesLUT.NumberOfTableValues = 256
anglesLUT.ScalarRangeInitialized = 1.0
anglesLUT.HSVWrap = 0
anglesLUT.VectorComponent = 0
anglesLUT.VectorMode = 'Magnitude'
anglesLUT.AllowDuplicateScalars = 1
anglesLUT.Annotations = []
anglesLUT.ActiveAnnotatedValues = []
anglesLUT.IndexedColors = []
anglesLUT.IndexedOpacities = []
# get opacity transfer function/opacity map for 'angles'
anglesPWF = GetOpacityTransferFunction('angles')
anglesPWF.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.33589355211648514, 0.625, 0.5, 0.0, 0.5680552565701278, 0.6691176295280457, 0.5, 0.0, 1.0471451860825267, 0.8676470518112183, 0.5, 0.0, 1.15586894219242, 0.6911764740943909, 0.5, 0.0, 1.5707963267948966, 0.8014705777168274, 0.5, 0.0]
anglesPWF.AllowDuplicateScalars = 1
anglesPWF.UseLogScale = 0
anglesPWF.ScalarRangeInitialized = 1
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
anglesLUT.ApplyPreset('Cool to Warm', True)
# anglesLUT.ApplyPreset('Warm to Cool (Extended)', True)
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XTitle = ' $\\theta_\\rho$ '
renderView1.AxesGrid.ZTitle = ' $\\theta$ '
renderView1.AxesGrid.XTitleFontSize = 20
renderView1.AxesGrid.ZTitleFontSize = 20
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowGrid = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.FacesToRender = 2
renderView1.AxesGrid.CullFrontface = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.Visibility = 1
renderView1.AxesGrid.DataScale = [0.1, 1.0, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XTitleFontSize = 22
renderView1.AxesGrid.ZTitleFontSize = 22
renderView1.AxesGrid.ZAxisUseCustomLabels = 1
renderView1.AxesGrid.ZAxisLabels = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowEdges = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XAxisPrecision = 1
renderView1.AxesGrid.XAxisLabels = [0.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisPrecision = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XAxisUseCustomLabels = 1
renderView1.AxesGrid.XAxisLabels = [0.0, -5.0, -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XLabelFontSize = 16
renderView1.AxesGrid.ZLabelFontSize = 16
renderView1.AxesGrid.XTitleFontSize = 65 #24
renderView1.AxesGrid.ZTitleFontSize = 65
renderView1.AxesGrid.XLabelFontSize = 45 #default:12
renderView1.AxesGrid.ZLabelFontSize = 45
# Properties modified on anglesLUT
anglesLUT.Annotations = ['', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0]
anglesLUT.IndexedOpacities = [1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0,785398163', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0,785398163', '$\\pi/4$']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0.785398163', '$\\pi/4$']
# get color legend/bar for anglesLUT in view renderView1
anglesLUTColorBar = GetScalarBar(anglesLUT, renderView1)
anglesLUTColorBar.AutoOrient = 1
anglesLUTColorBar.Orientation = 'Vertical'
anglesLUTColorBar.WindowLocation = 'LowerRightCorner'
anglesLUTColorBar.Position = [0.89, 0.02]
anglesLUTColorBar.Title = 'angles'
anglesLUTColorBar.ComponentTitle = ''
anglesLUTColorBar.TitleJustification = 'Centered'
anglesLUTColorBar.HorizontalTitle = 0
anglesLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
anglesLUTColorBar.TitleOpacity = 1.0
anglesLUTColorBar.TitleFontFamily = 'Arial'
anglesLUTColorBar.TitleFontFile = ''
anglesLUTColorBar.TitleBold = 0
anglesLUTColorBar.TitleItalic = 0
anglesLUTColorBar.TitleShadow = 0
anglesLUTColorBar.TitleFontSize = 16
anglesLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
anglesLUTColorBar.LabelOpacity = 1.0
anglesLUTColorBar.LabelFontFamily = 'Arial'
anglesLUTColorBar.LabelFontFile = ''
anglesLUTColorBar.LabelBold = 0
anglesLUTColorBar.LabelItalic = 0
anglesLUTColorBar.LabelShadow = 0
anglesLUTColorBar.LabelFontSize = 16
anglesLUTColorBar.AutomaticLabelFormat = 1
anglesLUTColorBar.LabelFormat = '%-#6.3g'
anglesLUTColorBar.DrawTickMarks = 1
anglesLUTColorBar.DrawTickLabels = 1
anglesLUTColorBar.UseCustomLabels = 0
anglesLUTColorBar.CustomLabels = []
anglesLUTColorBar.AddRangeLabels = 1
anglesLUTColorBar.RangeLabelFormat = '%-#6.1e'
anglesLUTColorBar.DrawAnnotations = 1
anglesLUTColorBar.AddRangeAnnotations = 0
anglesLUTColorBar.AutomaticAnnotations = 0
anglesLUTColorBar.DrawNanAnnotation = 0
anglesLUTColorBar.NanAnnotation = 'NaN'
anglesLUTColorBar.TextPosition = 'Ticks right/top, annotations left/bottom'
anglesLUTColorBar.ReverseLegend = 0
anglesLUTColorBar.ScalarBarThickness = 16
anglesLUTColorBar.ScalarBarLength = 0.33
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.DrawTickLabels = 0
anglesLUTColorBar.AddRangeLabels = 0
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.Title = 'angle $\\alpha$'
# anglesLUTColorBar.Title = 'angle $\\angle$'
anglesLUTColorBar.HorizontalTitle = 1
anglesLUTColorBar.TitleFontSize = 20
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.LabelFontSize = 20
anglesLUTColorBar.TitleFontSize = 24
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.LabelFontSize = 20
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.DrawTickMarks = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.GridColor = [0.1803921568627451, 0.20392156862745098, 0.21176470588235294]
# only label 2 axes...
renderView1.AxesGrid.AxesToLabel = 7
renderView1.OrientationAxesVisibility = 0
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [0.0, 7.295131721662212, 0.5]
renderView1.CameraFocalPoint = [0.0, 10.0, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = 0.7000714249274855
# DRAW LINE
#
# # create a new 'Line'
# line1 = Line()
#
# # find source
# xMLStructuredGridReader1 = FindSource('XMLStructuredGridReader1')
#
# # Properties modified on line1
# line1.Point1 = [0.3, 0.0, 0.0]
# line1.Point2 = [0.3, 0.0, 1.0]
# line1.Resolution = 500
# # Properties modified on line1Display
#
#
# # get active view
# renderView1 = GetActiveViewOrCreate('RenderView')
# # uncomment following to set a specific view size
# # renderView1.ViewSize = [1380, 518]
#
# # show data in view
# line1Display = Show(line1, renderView1)
#
# # trace defaults for the display properties.
# line1Display.Representation = 'Surface'
# line1Display.ColorArrayName = [None, '']
# line1Display.OSPRayScaleArray = 'Texture Coordinates'
# line1Display.OSPRayScaleFunction = 'PiecewiseFunction'
# line1Display.SelectOrientationVectors = 'None'
# line1Display.ScaleFactor = 0.1
# line1Display.SelectScaleArray = 'None'
# line1Display.GlyphType = 'Arrow'
# line1Display.GlyphTableIndexArray = 'None'
# line1Display.GaussianRadius = 0.005
# line1Display.SetScaleArray = ['POINTS', 'Texture Coordinates']
# line1Display.ScaleTransferFunction = 'PiecewiseFunction'
# line1Display.OpacityArray = ['POINTS', 'Texture Coordinates']
# line1Display.OpacityTransferFunction = 'PiecewiseFunction'
# line1Display.DataAxesGrid = 'GridAxesRepresentation'
# line1Display.PolarAxes = 'PolarAxesRepresentation'
#
# # init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
# line1Display.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
#
# # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
# line1Display.ScaleTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.2138364766881351, 0.625, 0.5, 0.0, 0.3616352081298828, 0.6691176295280457, 0.5, 0.0, 0.6666333299996667, 0.8676470518112183, 0.5, 0.0, 0.7358490228652954, 0.6911764740943909, 0.5, 0.0, 1.0, 0.8014705777168274, 0.5, 0.0]
#
# # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
# line1Display.OpacityTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.2138364766881351, 0.625, 0.5, 0.0, 0.3616352081298828, 0.6691176295280457, 0.5, 0.0, 0.6666333299996667, 0.8676470518112183, 0.5, 0.0, 0.7358490228652954, 0.6911764740943909, 0.5, 0.0, 1.0, 0.8014705777168274, 0.5, 0.0]
#
# # find source
# transform1 = FindSource('Transform1')
#
# # update the view to ensure updated data information
# renderView1.Update()
#
# # change solid color
# line1Display.AmbientColor = [1.0, 1.0, 0.4980392156862745]
# line1Display.DiffuseColor = [1.0, 1.0, 0.4980392156862745]
#
# # change representation type
# line1Display.SetRepresentationType('Points')
#
# line1Display.PointSize = 3.0
# # reset view to fit data bounds
# renderView1.ResetCamera(0.30000001192092896, 0.30000001192092896, 0.0, 0.0, 0.0, 1.0)
#
# # toggle 3D widget visibility (only when running from the GUI)
# Hide3DWidgets(proxy=line1)
#
# #### saving camera placements for all active views
#
# # current camera placement for renderView1
# renderView1.InteractionMode = '2D'
# renderView1.CameraPosition = [0.30000001192092896, -1.9318516525781368, 0.5]
# renderView1.CameraFocalPoint = [0.30000001192092896, 0.0, 0.5]
# renderView1.CameraViewUp = [0.0, 0.0, 1.0]
# renderView1.CameraParallelScale = 0.7320500000000002
#
# # reset view to fit data
# renderView1.ResetCamera()
if drawLine:
# create a new 'Line'
line1 = Line()
# Properties modified on line1
line1.Point1 = [0.3, 0.0, 0.0]
line1.Point2 = [0.3, 0.0, 1.0]
line1.Resolution = 400
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1046, 545]
# show data in view
line1Display = Show(line1, renderView1)
# trace defaults for the display properties.
line1Display.Representation = 'Surface'
line1Display.ColorArrayName = [None, '']
line1Display.OSPRayScaleArray = 'Texture Coordinates'
line1Display.OSPRayScaleFunction = 'PiecewiseFunction'
line1Display.SelectOrientationVectors = 'None'
line1Display.ScaleFactor = 0.1
line1Display.SelectScaleArray = 'None'
line1Display.GlyphType = 'Arrow'
line1Display.GlyphTableIndexArray = 'None'
line1Display.GaussianRadius = 0.005
line1Display.SetScaleArray = ['POINTS', 'Texture Coordinates']
line1Display.ScaleTransferFunction = 'PiecewiseFunction'
line1Display.OpacityArray = ['POINTS', 'Texture Coordinates']
line1Display.OpacityTransferFunction = 'PiecewiseFunction'
line1Display.DataAxesGrid = 'GridAxesRepresentation'
line1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
line1Display.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
line1Display.ScaleTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.2138364766881351, 0.625, 0.5, 0.0, 0.3616352081298828, 0.6691176295280457, 0.5, 0.0, 0.6666333299996667, 0.8676470518112183, 0.5, 0.0, 0.7358490228652954, 0.6911764740943909, 0.5, 0.0, 1.0, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
line1Display.OpacityTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.2138364766881351, 0.625, 0.5, 0.0, 0.3616352081298828, 0.6691176295280457, 0.5, 0.0, 0.6666333299996667, 0.8676470518112183, 0.5, 0.0, 0.7358490228652954, 0.6911764740943909, 0.5, 0.0, 1.0, 0.8014705777168274, 0.5, 0.0]
# find source
xMLStructuredGridReader1 = FindSource('XMLStructuredGridReader1')
# find source
transform1 = FindSource('Transform1')
# update the view to ensure updated data information
renderView1.Update()
# change representation type
line1Display.SetRepresentationType('Points')
# change solid color
line1Display.AmbientColor = [1.0, 1.0, 0.4980392156862745]
line1Display.DiffuseColor = [1.0, 1.0, 0.4980392156862745]
# Properties modified on line1Display
line1Display.PointSize = 3.0
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=line1)
# reset view to fit data
renderView1.ResetCamera()
# reset view to fit data
renderView1.ResetCamera()
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [0.0, -14.510745305395833, 0.5]
renderView1.CameraFocalPoint = [0.0, 5.0, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = 0.7506135276429463
#
# if case == 1:
if gamma == '0':
# get color transfer function/color map for 'angles'
anglesLUT = GetColorTransferFunction('angles')
anglesLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
anglesLUT.InterpretValuesAsCategories = 0
anglesLUT.AnnotationsInitialized = 0
anglesLUT.ShowCategoricalColorsinDataRangeOnly = 0
anglesLUT.RescaleOnVisibilityChange = 0
anglesLUT.EnableOpacityMapping = 1
anglesLUT.RGBPoints = [0.0, 0.23137254902, 0.298039215686, 0.752941176471, 0.9632241725921631, 0.865, 0.865, 0.865, 1.5707963267948966, 0.705882352941, 0.0156862745098, 0.149019607843]
anglesLUT.UseLogScale = 0
anglesLUT.ColorSpace = 'Diverging'
anglesLUT.UseBelowRangeColor = 0
anglesLUT.BelowRangeColor = [0.0, 0.0, 0.0]
anglesLUT.UseAboveRangeColor = 0
anglesLUT.AboveRangeColor = [0.5, 0.5, 0.5]
anglesLUT.NanColor = [1.0, 1.0, 0.0]
anglesLUT.NanOpacity = 1.0
anglesLUT.Discretize = 1
anglesLUT.NumberOfTableValues = 256
anglesLUT.ScalarRangeInitialized = 1.0
anglesLUT.HSVWrap = 0
anglesLUT.VectorComponent = 0
anglesLUT.VectorMode = 'Magnitude'
anglesLUT.AllowDuplicateScalars = 1
anglesLUT.Annotations = ['1.57', '$\\pi / 2$', '0.78', '$\\pi/4$', '0', '0']
anglesLUT.ActiveAnnotatedValues = []
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0, 1.0, 1.0]
# get opacity transfer function/opacity map for 'angles'
anglesPWF = GetOpacityTransferFunction('angles')
anglesPWF.Points = [0.0, 0.136764707416296, 0.5, 0.0, 0.705621357414266, 1.0, 0.5, 0.0, 0.82168139570297, 1.0, 0.5, 0.0, 0.9799451305746117, 1.0, 0.5, 0.0, 1.0960051688633157, 1.0, 0.5, 0.0, 1.5707963267948966, 1.0, 0.5, 0.0]
anglesPWF.AllowDuplicateScalars = 1
anglesPWF.UseLogScale = 0
anglesPWF.ScalarRangeInitialized = 1
# Properties modified on anglesLUT
anglesLUT.InterpretValuesAsCategories = 1
anglesLUT.AnnotationsInitialized = 1
# Properties modified on anglesLUT
anglesLUT.Annotations = ['1.57', '$\\pi / 2$', '0.78', '$\\pi/4$', '0', '0', '1.5707963267948966', '1.5708']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['1.57', '$\\pi / 2$', '0.78', '$\\pi/4$', '0', '0']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['1.57', '$\\pi / 2$', '0', '0']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['1.5707963267948966', '$\\pi / 2$', '0', '0']
# Properties modified on anglesLUT
anglesLUT.IndexedColors = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
# Properties modified on anglesLUT
anglesLUT.IndexedColors = [1.0, 0.0, 0.0, 0.23137254901960785, 0.2980392156862745, 0.7529411764705882]
# Properties modified on anglesLUT
anglesLUT.IndexedColors = [0.7058823529411765, 0.01568627450980392, 0.14901960784313725, 0.23137254901960785, 0.2980392156862745, 0.7529411764705882]
# Properties modified on anglesLUT
anglesLUT.IndexedOpacities = [1.0, 0.02]
# Properties modified on anglesLUT
anglesLUT.IndexedOpacities = [1.0, 0.05]
# Properties modified on anglesLUT
anglesLUT.IndexedOpacities = [1.0, 0.1]
anglesLUT.IndexedOpacities = [1.0, 1.0]
# #TEST: (only for 100SP..)
# anglesLUT.IndexedOpacities = [1.0, 0.03]
# transform1Display.Opacity = 0.1 #overall Opacity
if curvature == 1 :
# find source
transform1 = FindSource('Transform1')
# set active source
SetActiveSource(transform1)
# get color transfer function/color map for 'angles'
anglesLUT = GetColorTransferFunction('angles')
anglesLUT.RGBPoints = [0.0, 0.23137254902, 0.298039215686, 0.752941176471, 0.7853981633974483, 0.865, 0.865, 0.865, 1.5707963267948966, 0.705882352941, 0.0156862745098, 0.149019607843]
anglesLUT.ScalarRangeInitialized = 1.0
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0.785398163', '$\\pi/4$']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0, 1.0]
# get opacity transfer function/opacity map for 'angles'
anglesPWF = GetOpacityTransferFunction('angles')
anglesPWF.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.33589355211648514, 0.625, 0.5, 0.0, 0.5680552565701278, 0.6691176295280457, 0.5, 0.0, 1.0471451860825267, 0.8676470518112183, 0.5, 0.0, 1.15586894219242, 0.6911764740943909, 0.5, 0.0, 1.5707963267948966, 0.8014705777168274, 0.5, 0.0]
anglesPWF.ScalarRangeInitialized = 1
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1046, 545]
# get display properties
transform1Display = GetDisplayProperties(transform1, view=renderView1)
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'curvature'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(anglesLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
transform1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'curvature'
curvatureLUT = GetColorTransferFunction('curvature')
curvatureLUT.RGBPoints = [-74.1, 0.001462, 0.000466, 0.013866, -73.517583, 0.002258, 0.001295, 0.018331, -72.93531449999999, 0.003279, 0.002305, 0.023708, -72.3528975, 0.004512, 0.00349, 0.029965, -71.77062899999999, 0.00595, 0.004843, 0.03713, -71.18821199999998, 0.007588, 0.006356, 0.044973, -70.60594350000001, 0.009426, 0.008022, 0.052844, -70.02352650000002, 0.011465, 0.009828, 0.06075, -69.44110949999998, 0.013708, 0.011771, 0.068667, -68.858841, 0.016156, 0.01384, 0.076603, -68.276424, 0.018815, 0.016026, 0.084584, -67.6941555, 0.021692, 0.01832, 0.09261, -67.1117385, 0.024792, 0.020715, 0.100676, -66.52946999999999, 0.028123, 0.023201, 0.108787, -65.947053, 0.031696, 0.025765, 0.116965, -65.36463599999999, 0.03552, 0.028397, 0.125209, -64.78236749999999, 0.039608, 0.03109, 0.133515, -64.19995049999999, 0.04383, 0.03383, 0.141886, -63.61768199999998, 0.048062, 0.036607, 0.150327, -63.03526499999998, 0.05232, 0.039407, 0.158841, -62.452996500000005, 0.056615, 0.04216, 0.167446, -61.870579500000005, 0.060949, 0.044794, 0.176129, -61.28816249999998, 0.06533, 0.047318, 0.184892, -60.705894, 0.069764, 0.049726, 0.193735, -60.12347700000001, 0.074257, 0.052017, 0.20266, -59.541208499999996, 0.078815, 0.054184, 0.211667, -58.9587915, 0.083446, 0.056225, 0.220755, -58.37652299999999, 0.088155, 0.058133, 0.229922, -57.79410599999999, 0.092949, 0.059904, 0.239164, -57.21183749999999, 0.097833, 0.061531, 0.248477, -56.62942049999998, 0.102815, 0.06301, 0.257854, -56.04700349999999, 0.107899, 0.064335, 0.267289, -55.464734999999976, 0.113094, 0.065492, 0.276784, -54.882317999999984, 0.118405, 0.066479, 0.286321, -54.30004950000001, 0.123833, 0.067295, 0.295879, -53.71763250000001, 0.12938, 0.067935, 0.305443, -53.135363999999996, 0.135053, 0.068391, 0.315, -52.552947, 0.140858, 0.068654, 0.324538, -51.970530000000004, 0.146785, 0.068738, 0.334011, -51.3882615, 0.152839, 0.068637, 0.343404, -50.8058445, 0.159018, 0.068354, 0.352688, -50.22357599999999, 0.165308, 0.067911, 0.361816, -49.64115899999999, 0.171713, 0.067305, 0.370771, -49.05889049999998, 0.178212, 0.066576, 0.379497, -48.47647349999998, 0.184801, 0.065732, 0.387973, -47.89405649999999, 0.19146, 0.064818, 0.396152, -47.31178800000001, 0.198177, 0.063862, 0.404009, -46.729370999999986, 0.204935, 0.062907, 0.411514, -46.1471025, 0.211718, 0.061992, 0.418647, -45.56468550000001, 0.218512, 0.061158, 0.425392, -44.982417, 0.225302, 0.060445, 0.431742, -44.400000000000006, 0.232077, 0.059889, 0.437695, -43.817583, 0.238826, 0.059517, 0.443256, -43.235314499999994, 0.245543, 0.059352, 0.448436, -42.652897499999995, 0.25222, 0.059415, 0.453248, -42.07062899999999, 0.258857, 0.059706, 0.45771, -41.48821199999999, 0.265447, 0.060237, 0.46184, -40.90594349999998, 0.271994, 0.060994, 0.46566, -40.323526499999986, 0.278493, 0.061978, 0.46919, -39.741109499999986, 0.284951, 0.063168, 0.472451, -39.158840999999974, 0.291366, 0.064553, 0.475462, -38.57642399999998, 0.29774, 0.066117, 0.478243, -37.994155500000005, 0.304081, 0.067835, 0.480812, -37.411738500000006, 0.310382, 0.069702, 0.483186, -36.82947, 0.316654, 0.07169, 0.48538, -36.247053, 0.322899, 0.073782, 0.487408, -35.664636, 0.329114, 0.075972, 0.489287, -35.0823675, 0.335308, 0.078236, 0.491024, -34.4999505, 0.341482, 0.080564, 0.492631, -33.917681999999985, 0.347636, 0.082946, 0.494121, -33.33526499999999, 0.353773, 0.085373, 0.495501, -32.752996500000016, 0.359898, 0.087831, 0.496778, -32.17057949999998, 0.366012, 0.090314, 0.49796, -31.58816249999999, 0.372116, 0.092816, 0.499053, -31.005894000000012, 0.378211, 0.095332, 0.500067, -30.423476999999977, 0.384299, 0.097855, 0.501002, -29.8412085, 0.390384, 0.100379, 0.501864, -29.258791500000008, 0.396467, 0.102902, 0.502658, -28.676522999999996, 0.402548, 0.10542, 0.503386, -28.094105999999996, 0.408629, 0.10793, 0.504052, -27.51183749999999, 0.414709, 0.110431, 0.504662, -26.929420499999992, 0.420791, 0.11292, 0.505215, -26.347003499999992, 0.426877, 0.115395, 0.505714, -25.764734999999988, 0.432967, 0.117855, 0.50616, -25.182317999999988, 0.439062, 0.120298, 0.506555, -24.600049499999976, 0.445163, 0.122724, 0.506901, -24.017632499999984, 0.451271, 0.125132, 0.507198, -23.435364000000007, 0.457386, 0.127522, 0.507448, -22.852946999999972, 0.463508, 0.129893, 0.507652, -22.270530000000008, 0.46964, 0.132245, 0.507809, -21.688261500000003, 0.47578, 0.134577, 0.507921, -21.105844500000003, 0.481929, 0.136891, 0.507989, -20.523576, 0.488088, 0.139186, 0.508011, -19.941159, 0.494258, 0.141462, 0.507988, -19.358890499999987, 0.500438, 0.143719, 0.50792, -18.776473499999994, 0.506629, 0.145958, 0.507806, -18.194056499999995, 0.512831, 0.148179, 0.507648, -17.611787999999983, 0.519045, 0.150383, 0.507443, -17.02937099999999, 0.52527, 0.152569, 0.507192, -16.447102500000014, 0.531507, 0.154739, 0.506895, -15.864685499999979, 0.537755, 0.156894, 0.506551, -15.282417000000002, 0.544015, 0.159033, 0.506159, -14.70000000000001, 0.550287, 0.161158, 0.505719, -14.117582999999975, 0.556571, 0.163269, 0.50523, -13.535314499999998, 0.562866, 0.165368, 0.504692, -12.952897500000006, 0.569172, 0.167454, 0.504105, -12.370628999999994, 0.57549, 0.16953, 0.503466, -11.788211999999994, 0.581819, 0.171596, 0.502777, -11.20594349999999, 0.588158, 0.173652, 0.502035, -10.62352649999999, 0.594508, 0.175701, 0.501241, -10.04110949999999, 0.600868, 0.177743, 0.500394, -9.458840999999978, 0.607238, 0.179779, 0.499492, -8.876423999999986, 0.613617, 0.181811, 0.498536, -8.294155499999974, 0.620005, 0.18384, 0.497524, -7.71173850000001, 0.626401, 0.185867, 0.496456, -7.129469999999998, 0.632805, 0.187893, 0.495332, -6.547053000000005, 0.639216, 0.189921, 0.49415, -5.964636000000013, 0.645633, 0.191952, 0.49291, -5.382367500000001, 0.652056, 0.193986, 0.491611, -4.7999505000000084, 0.658483, 0.196027, 0.490253, -4.217681999999996, 0.664915, 0.198075, 0.488836, -3.6352649999999898, 0.671349, 0.200133, 0.487358, -3.052996499999992, 0.677786, 0.202203, 0.485819, -2.4705794999999853, 0.684224, 0.204286, 0.484219, -1.8881624999999929, 0.690661, 0.206384, 0.482558, -1.3058939999999808, 0.697098, 0.208501, 0.480835, -0.7234769999999884, 0.703532, 0.210638, 0.479049, -0.14120850000000473, 0.709962, 0.212797, 0.477201, 0.4412085000000161, 0.716387, 0.214982, 0.47529, 1.0234770000000282, 0.722805, 0.217194, 0.473316, 1.6058939999999922, 0.729216, 0.219437, 0.471279, 2.1881625000000042, 0.735616, 0.221713, 0.46918, 2.7705794999999966, 0.742004, 0.224025, 0.467018, 3.3529965000000033, 0.748378, 0.226377, 0.464794, 3.935265000000001, 0.754737, 0.228772, 0.462509, 4.517682000000008, 0.761077, 0.231214, 0.460162, 5.099950499999977, 0.767398, 0.233705, 0.457755, 5.682367500000012, 0.773695, 0.236249, 0.455289, 6.264636000000024, 0.779968, 0.238851, 0.452765, 6.847052999999988, 0.786212, 0.241514, 0.450184, 7.429470000000009, 0.792427, 0.244242, 0.447543, 8.011738500000021, 0.798608, 0.24704, 0.444848, 8.594155499999985, 0.804752, 0.249911, 0.442102, 9.176423999999997, 0.810855, 0.252861, 0.439305, 9.758841000000032, 0.816914, 0.255895, 0.436461, 10.341109500000002, 0.822926, 0.259016, 0.433573, 10.923526500000008, 0.828886, 0.262229, 0.430644, 11.5059435, 0.834791, 0.26554, 0.427671, 12.088212000000013, 0.840636, 0.268953, 0.424666, 12.670629000000005, 0.846416, 0.272473, 0.421631, 13.252897500000017, 0.852126, 0.276106, 0.418573, 13.83531450000001, 0.857763, 0.279857, 0.415496, 14.417582999999993, 0.86332, 0.283729, 0.412403, 15.000000000000014, 0.868793, 0.287728, 0.409303, 15.582416999999978, 0.874176, 0.291859, 0.406205, 16.16468549999999, 0.879464, 0.296125, 0.403118, 16.747102500000025, 0.884651, 0.30053, 0.400047, 17.329370999999995, 0.889731, 0.305079, 0.397002, 17.911788, 0.8947, 0.309773, 0.393995, 18.4940565, 0.899552, 0.314616, 0.391037, 19.076473500000006, 0.904281, 0.31961, 0.388137, 19.6588905, 0.908884, 0.324755, 0.385308, 20.24115900000001, 0.913354, 0.330052, 0.382563, 20.823576000000003, 0.917689, 0.3355, 0.379915, 21.405844499999986, 0.921884, 0.341098, 0.377376, 21.988261500000007, 0.925937, 0.346844, 0.374959, 22.57053000000002, 0.929845, 0.352734, 0.372677, 23.152946999999983, 0.933606, 0.358764, 0.370541, 23.73536400000002, 0.937221, 0.364929, 0.368567, 24.31763250000003, 0.940687, 0.371224, 0.366762, 24.900049499999994, 0.944006, 0.377643, 0.365136, 25.482318000000006, 0.94718, 0.384178, 0.363701, 26.064735000000027, 0.95021, 0.39082, 0.362468, 26.64700350000001, 0.953099, 0.397563, 0.361438, 27.229420500000003, 0.955849, 0.4044, 0.360619, 27.811837499999996, 0.958464, 0.411324, 0.360014, 28.394106000000008, 0.960949, 0.418323, 0.35963, 28.976523000000014, 0.96331, 0.42539, 0.359469, 29.558791500000012, 0.965549, 0.432519, 0.359529, 30.141208499999976, 0.967671, 0.439703, 0.35981, 30.72347699999999, 0.96968, 0.446936, 0.360311, 31.305894000000023, 0.971582, 0.45421, 0.36103, 31.888162500000035, 0.973381, 0.46152, 0.361965, 32.4705795, 0.975082, 0.468861, 0.363111, 33.05299650000002, 0.97669, 0.476226, 0.364466, 33.635265000000004, 0.97821, 0.483612, 0.366025, 34.217681999999996, 0.979645, 0.491014, 0.367783, 34.79995050000001, 0.981, 0.498428, 0.369734, 35.3823675, 0.982279, 0.505851, 0.371874, 35.964635999999985, 0.983485, 0.51328, 0.374198, 36.547053000000005, 0.984622, 0.520713, 0.376698, 37.12947000000001, 0.985693, 0.528148, 0.379371, 37.71173849999998, 0.9867, 0.535582, 0.38221, 38.294155500000016, 0.987646, 0.543015, 0.38521, 38.87642400000003, 0.988533, 0.550446, 0.388365, 39.45884099999999, 0.989363, 0.557873, 0.391671, 40.041109500000005, 0.990138, 0.565296, 0.395122, 40.623526500000025, 0.990871, 0.572706, 0.398714, 41.20594349999999, 0.991558, 0.580107, 0.402441, 41.788212, 0.992196, 0.587502, 0.406299, 42.370628999999994, 0.992785, 0.594891, 0.410283, 42.952897500000006, 0.993326, 0.602275, 0.41439, 43.53531450000001, 0.993834, 0.609644, 0.418613, 44.11758300000001, 0.994309, 0.616999, 0.42295, 44.70000000000002, 0.994738, 0.62435, 0.427397, 45.28241700000001, 0.995122, 0.631696, 0.431951, 45.86468550000002, 0.99548, 0.639027, 0.436607, 46.447102499999986, 0.99581, 0.646344, 0.441361, 47.029371, 0.996096, 0.653659, 0.446213, 47.61178800000002, 0.996341, 0.660969, 0.45116, 48.1940565, 0.99658, 0.668256, 0.456192, 48.776473499999994, 0.996775, 0.675541, 0.461314, 49.35889050000003, 0.996925, 0.682828, 0.466526, 49.941159, 0.997077, 0.690088, 0.471811, 50.523576000000006, 0.997186, 0.697349, 0.477182, 51.1058445, 0.997254, 0.704611, 0.482635, 51.68826150000001, 0.997325, 0.711848, 0.488154, 52.27052999999998, 0.997351, 0.719089, 0.493755, 52.852947000000015, 0.997351, 0.726324, 0.499428, 53.43536400000001, 0.997341, 0.733545, 0.505167, 54.01763249999999, 0.997285, 0.740772, 0.510983, 54.60004950000001, 0.997228, 0.747981, 0.516859, 55.18231800000004, 0.997138, 0.75519, 0.522806, 55.764735, 0.997019, 0.762398, 0.528821, 56.3470035, 0.996898, 0.769591, 0.534892, 56.92942050000002, 0.996727, 0.776795, 0.541039, 57.511837499999984, 0.996571, 0.783977, 0.547233, 58.09410600000001, 0.996369, 0.791167, 0.553499, 58.676523, 0.996162, 0.798348, 0.55982, 59.2587915, 0.995932, 0.805527, 0.566202, 59.84120850000002, 0.99568, 0.812706, 0.572645, 60.42347700000002, 0.995424, 0.819875, 0.57914, 61.005893999999984, 0.995131, 0.827052, 0.585701, 61.58816249999998, 0.994851, 0.834213, 0.592307, 62.17057950000003, 0.994524, 0.841387, 0.598983, 62.752996499999995, 0.994222, 0.84854, 0.605696, 63.33526499999999, 0.993866, 0.855711, 0.612482, 63.91768200000001, 0.993545, 0.862859, 0.619299, 64.49995050000001, 0.99317, 0.870024, 0.626189, 65.0823675, 0.992831, 0.877168, 0.633109, 65.664636, 0.99244, 0.88433, 0.640099, 66.247053, 0.992089, 0.89147, 0.647116, 66.82947000000001, 0.991688, 0.898627, 0.654202, 67.41173850000001, 0.991332, 0.905763, 0.661309, 67.9941555, 0.99093, 0.912915, 0.668481, 68.57642399999997, 0.99057, 0.920049, 0.675675, 69.15884100000002, 0.990175, 0.927196, 0.682926, 69.74110950000002, 0.989815, 0.934329, 0.690198, 70.32352649999999, 0.989434, 0.94147, 0.697519, 70.9059435, 0.989077, 0.948604, 0.704863, 71.48821200000003, 0.988717, 0.955742, 0.712242, 72.070629, 0.988367, 0.962878, 0.719649, 72.6528975, 0.988033, 0.970012, 0.727077, 73.23531449999999, 0.987691, 0.977154, 0.734536, 73.81758300000001, 0.987387, 0.984288, 0.742002, 74.4, 0.987053, 0.991438, 0.749504]
curvatureLUT.ColorSpace = 'RGB'
curvatureLUT.NanColor = [0.0, 1.0, 0.0]
curvatureLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'curvature'
curvaturePWF = GetOpacityTransferFunction('curvature')
curvaturePWF.Points = [-74.1, 0.8602941036224365, 0.5, 0.0, -42.34528321181193, 0.625, 0.5, 0.0, -20.397171592712397, 0.6691176295280457, 0.5, 0.0, 24.89504950495052, 0.8676470518112183, 0.5, 0.0, 35.173579895496374, 0.6911764740943909, 0.5, 0.0, 74.4, 0.8014705777168274, 0.5, 0.0]
curvaturePWF.ScalarRangeInitialized = 1
# create a new 'Contour'
contour1 = Contour(Input=transform1)
contour1.ContourBy = ['POINTS', 'Type']
contour1.Isosurfaces = [2.0]
contour1.PointMergeMethod = 'Uniform Binning'
# find source
line1 = FindSource('Line1')
# find source
xMLStructuredGridReader1 = FindSource('XMLStructuredGridReader1')
# Properties modified on contour1
contour1.ContourBy = ['POINTS', 'curvature']
contour1.Isosurfaces = [0.0]
# show data in view
contour1Display = Show(contour1, renderView1)
# trace defaults for the display properties.
contour1Display.Representation = 'Surface'
contour1Display.ColorArrayName = ['POINTS', 'curvature']
contour1Display.LookupTable = curvatureLUT
contour1Display.OSPRayScaleArray = 'curvature'
contour1Display.OSPRayScaleFunction = 'PiecewiseFunction'
contour1Display.SelectOrientationVectors = 'None'
contour1Display.ScaleFactor = 0.08543854954749906
contour1Display.SelectScaleArray = 'curvature'
contour1Display.GlyphType = 'Arrow'
contour1Display.GlyphTableIndexArray = 'curvature'
contour1Display.GaussianRadius = 0.004271927477374953
contour1Display.SetScaleArray = ['POINTS', 'curvature']
contour1Display.ScaleTransferFunction = 'PiecewiseFunction'
contour1Display.OpacityArray = ['POINTS', 'curvature']
contour1Display.OpacityTransferFunction = 'PiecewiseFunction'
contour1Display.DataAxesGrid = 'GridAxesRepresentation'
contour1Display.PolarAxes = 'PolarAxesRepresentation'
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
contour1Display.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
contour1Display.ScaleTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 2.5142493840581125e-39, 0.625, 0.5, 0.0, 4.252039284300157e-39, 0.6691176295280457, 0.5, 0.0, 7.838150278676329e-39, 0.8676470518112183, 0.5, 0.0, 8.651975477491057e-39, 0.6911764740943909, 0.5, 0.0, 1.1757813367477812e-38, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
contour1Display.OpacityTransferFunction.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 2.5142493840581125e-39, 0.625, 0.5, 0.0, 4.252039284300157e-39, 0.6691176295280457, 0.5, 0.0, 7.838150278676329e-39, 0.8676470518112183, 0.5, 0.0, 8.651975477491057e-39, 0.6911764740943909, 0.5, 0.0, 1.1757813367477812e-38, 0.8014705777168274, 0.5, 0.0]
# show color bar/color legend
contour1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# turn off scalar coloring
ColorBy(contour1Display, None)
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(curvatureLUT, renderView1)
# change solid color
contour1Display.AmbientColor = [1.0, 1.0, 0.4980392156862745]
contour1Display.DiffuseColor = [1.0, 1.0, 0.4980392156862745]
# change solid color
contour1Display.AmbientColor = [0.0, 0.0, 0.0]
contour1Display.DiffuseColor = [0.0, 0.0, 0.0]
# set active source
SetActiveSource(transform1)
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
curvatureLUT.ApplyPreset('Cold and Hot', True)
# set active source
SetActiveSource(contour1)
# change solid color
contour1Display.AmbientColor = [1.0, 1.0, 0.4980392156862745]
contour1Display.DiffuseColor = [1.0, 1.0, 0.4980392156862745]
# change solid color
contour1Display.AmbientColor = [1.0, 1.0, 1.0]
contour1Display.DiffuseColor = [1.0, 1.0, 1.0]
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [0.0, -14.510745305395833, 0.5]
renderView1.CameraFocalPoint = [0.0, 5.0, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = 0.7506135276429463
curvatureLUTColorBar = GetScalarBar(curvatureLUT, renderView1)
curvatureLUTColorBar.Title = 'curvature'
curvatureLUTColorBar.ComponentTitle = ''
# Properties modified on curvatureLUTColorBar
curvatureLUTColorBar.Title = '$ \\kappa $'
curvatureLUTColorBar.HorizontalTitle = 1
curvatureLUTColorBar.TitleFontSize = 24
curvatureLUTColorBar.LabelFontSize = 20
# get active source.
contour1 = GetActiveSource()
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1046, 545]
# get display properties
contour1Display = GetDisplayProperties(contour1, view=renderView1)
# change representation type
contour1Display.SetRepresentationType('Surface')
# change representation type
contour1Display.SetRepresentationType('Points')
# Properties modified on contour1Display
contour1Display.PointSize = 3.0
# Properties modified on contour1Display
contour1Display.PointSize = 2.0
# Properties modified on contour1Display
contour1Display.RenderPointsAsSpheres = 0
# Properties modified on contour1Display
contour1Display.RenderPointsAsSpheres = 1
# rescale color and/or opacity maps used to exactly fit the current data range
transform1Display.RescaleTransferFunctionToDataRange(False, True)
if discreteColor:
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
curvatureLUT.ApplyPreset('KAAMS Step', True)
# invert the transfer function
curvatureLUT.InvertTransferFunction()
# if case == 3:
# if gamma != '0' and gamma != 'infinity':
if smallerRegion:
paraview.simple._DisableFirstRenderCameraReset()
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1184, 905]
#### saving camera placements for all active views
renderView1.AxesGrid.DataScale = [0.0666667, 1.0, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisLabels = [ 0.4, 0.5, 0.6]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowEdges = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XAxisPrecision = 1
renderView1.AxesGrid.XAxisLabels = [0.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisPrecision = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XAxisUseCustomLabels = 1
renderView1.AxesGrid.XAxisLabels = [-2.0, -1.0, 0.0, 1.0]
# current camera placement for renderView1
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [0.0, -14.510745305395833, 0.5]
renderView1.CameraFocalPoint = [0.0, 5.0, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = 0.7506135276429463
if gamma == '0' or gamma == 'infinity':
# Properties modified on transform1Display
transform1Display.GaussianRadius = 0.00075
else :
# transform1Display.GaussianRadius= 0.00001
transform1Display.GaussianRadius= 0.00075
# reset view to fit data
renderView1.ResetCamera()
# # current camera placement for renderView1
# renderView1.InteractionMode = '2D'
# renderView1.CameraPosition = [-0.03333335, 9.453589701883667, 0.5]
# renderView1.CameraFocalPoint = [-0.03333335, 10.0, 0.5]
# renderView1.CameraViewUp = [0.0, 0.0, 1.0]
# renderView1.CameraParallelScale = 0.14142139159265296
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
# ----------------- EXPORT -----------------
# save screenshot
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[1257, 934])
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[2514, 1868])
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[1063, 657])
outputName = '/home/klaus/Desktop/2DPhaseDiagram_' + str(gamma) + ".png"
# SaveScreenshot('/home/klaus/Desktop/2DPhaseDiagram.png', renderView1, ImageResolution=[2126, 1314])
SaveScreenshot(outputName , renderView1, ImageResolution=[2126, 1314])
# export view
# ExportView('/home/klaus/Desktop/PhaseDiagramPlot.pdf', view=renderView1)
## trace generated using paraview version 5.7.0
#
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
case = 1
case = 2
case = 3
#
drawLine = False
# prestrain = 0
# gamma = 'infinity'
# angles = 1
case = 1 # 1: prestrain , 2: elasticRatio , 3: angle
# trace generated using paraview version 5.7.0
#
# To ensure correct image size when batch processing, please search
# for and uncomment the line `# renderView*.ViewSize = [*,*]`
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._DisableFirstRenderCameraReset()
# create a new 'XML Structured Grid Reader'
elasticRatiovts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/ElasticRatio.vts'])
elasticRatiovts.PointArrayStatus = ['elasticRatio', 'prestrainRatio', 'Type', 'angles', 'curvature']
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1067, 518]
# show data in view
elasticRatiovtsDisplay = Show(elasticRatiovts, renderView1)
# get color transfer function/color map for 'elasticRatio'
elasticRatioLUT = GetColorTransferFunction('elasticRatio')
elasticRatioLUT.RGBPoints = [0.3303091106505249, 0.001462, 0.000466, 0.013866, 0.33293563447422064, 0.002258, 0.001295, 0.018331, 0.33556148860800733, 0.003279, 0.002305, 0.023708, 0.33818801243170304, 0.004512, 0.00349, 0.029965, 0.34081386656548973, 0.00595, 0.004843, 0.03713, 0.3434403903891855, 0.007588, 0.006356, 0.044973, 0.346066244522972, 0.009426, 0.008022, 0.052844, 0.3486927683466678, 0.011465, 0.009828, 0.06075, 0.3513192921703637, 0.013708, 0.011771, 0.068667, 0.3539451463041502, 0.016156, 0.01384, 0.076603, 0.35657167012784596, 0.018815, 0.016026, 0.084584, 0.35919752426163265, 0.021692, 0.01832, 0.09261, 0.3618240480853284, 0.024792, 0.020715, 0.100676, 0.36444990221911505, 0.028123, 0.023201, 0.108787, 0.3670764260428108, 0.031696, 0.025765, 0.116965, 0.3697029498665066, 0.03552, 0.028397, 0.125209, 0.3723288040002933, 0.039608, 0.03109, 0.133515, 0.37495532782398905, 0.04383, 0.03383, 0.141886, 0.3775811819577757, 0.048062, 0.036607, 0.150327, 0.38020770578147145, 0.05232, 0.039407, 0.158841, 0.38283355991525797, 0.056615, 0.04216, 0.167446, 0.38546008373895374, 0.060949, 0.044794, 0.176129, 0.3880866075626497, 0.06533, 0.047318, 0.184892, 0.39071246169643614, 0.069764, 0.049726, 0.193735, 0.3933389855201319, 0.074257, 0.052017, 0.20266, 0.3959648396539186, 0.078815, 0.054184, 0.211667, 0.39859136347761437, 0.083446, 0.056225, 0.220755, 0.40121721761140106, 0.088155, 0.058133, 0.229922, 0.4038437414350968, 0.092949, 0.059904, 0.239164, 0.40646959556888346, 0.097833, 0.061531, 0.248477, 0.4090961193925792, 0.102815, 0.06301, 0.257854, 0.411722643216275, 0.107899, 0.064335, 0.267289, 0.41434849735006163, 0.113094, 0.065492, 0.276784, 0.4169750211737574, 0.118405, 0.066479, 0.286321, 0.4196008753075439, 0.123833, 0.067295, 0.295879, 0.4222273991312397, 0.12938, 0.067935, 0.305443, 0.4248532532650264, 0.135053, 0.068391, 0.315, 0.42747977708872215, 0.140858, 0.068654, 0.324538, 0.43010630091241786, 0.146785, 0.068738, 0.334011, 0.43273215504620455, 0.152839, 0.068637, 0.343404, 0.4353586788699003, 0.159018, 0.068354, 0.352688, 0.437984533003687, 0.165308, 0.067911, 0.361816, 0.4406110568273828, 0.171713, 0.067305, 0.370771, 0.4432369109611694, 0.178212, 0.066576, 0.379497, 0.4458634347848652, 0.184801, 0.065732, 0.387973, 0.44848995860856095, 0.19146, 0.064818, 0.396152, 0.45111581274234747, 0.198177, 0.063862, 0.404009, 0.45374233656604335, 0.204935, 0.062907, 0.411514, 0.4563681906998299, 0.211718, 0.061992, 0.418647, 0.4589947145235257, 0.218512, 0.061158, 0.425392, 0.4616205686573123, 0.225302, 0.060445, 0.431742, 0.4642470924810081, 0.232077, 0.059889, 0.437695, 0.46687361630470386, 0.238826, 0.059517, 0.443256, 0.4694994704384905, 0.245543, 0.059352, 0.448436, 0.47212599426218627, 0.25222, 0.059415, 0.453248, 0.47475184839597295, 0.258857, 0.059706, 0.45771, 0.4773783722196687, 0.265447, 0.060237, 0.46184, 0.4800042263534554, 0.271994, 0.060994, 0.46566, 0.4826307501771512, 0.278493, 0.061978, 0.46919, 0.4852572740008469, 0.284951, 0.063168, 0.472451, 0.4878831281346336, 0.291366, 0.064553, 0.475462, 0.4905096519583293, 0.29774, 0.066117, 0.478243, 0.49313550609211587, 0.304081, 0.067835, 0.480812, 0.49576202991581164, 0.310382, 0.069702, 0.483186, 0.4983878840495983, 0.316654, 0.07169, 0.48538, 0.5010144078732941, 0.322899, 0.073782, 0.487408, 0.5036409316969899, 0.329114, 0.075972, 0.489287, 0.5062667858307764, 0.335308, 0.078236, 0.491024, 0.5088933096544722, 0.341482, 0.080564, 0.492631, 0.5115191637882589, 0.347636, 0.082946, 0.494121, 0.5141456876119547, 0.353773, 0.085373, 0.495501, 0.5167715417457412, 0.359898, 0.087831, 0.496778, 0.5193980655694371, 0.366012, 0.090314, 0.49796, 0.5220245893931329, 0.372116, 0.092816, 0.499053, 0.5246504435269194, 0.378211, 0.095332, 0.500067, 0.5272769673506152, 0.384299, 0.097855, 0.501002, 0.5299028214844018, 0.390384, 0.100379, 0.501864, 0.5325293453080976, 0.396467, 0.102902, 0.502658, 0.5351551994418843, 0.402548, 0.10542, 0.503386, 0.53778172326558, 0.408629, 0.10793, 0.504052, 0.5404075773993666, 0.414709, 0.110431, 0.504662, 0.5430341012230624, 0.420791, 0.11292, 0.505215, 0.5456606250467582, 0.426877, 0.115395, 0.505714, 0.5482864791805449, 0.432967, 0.117855, 0.50616, 0.5509130030042406, 0.439062, 0.120298, 0.506555, 0.5535388571380273, 0.445163, 0.122724, 0.506901, 0.5561653809617231, 0.451271, 0.125132, 0.507198, 0.5587912350955095, 0.457386, 0.127522, 0.507448, 0.5614177589192055, 0.463508, 0.129893, 0.507652, 0.5640442827429011, 0.46964, 0.132245, 0.507809, 0.5666701368766878, 0.47578, 0.134577, 0.507921, 0.5692966607003835, 0.481929, 0.136891, 0.507989, 0.5719225148341702, 0.488088, 0.139186, 0.508011, 0.574549038657866, 0.494258, 0.141462, 0.507988, 0.5771748927916527, 0.500438, 0.143719, 0.50792, 0.5798014166153485, 0.506629, 0.145958, 0.507806, 0.5824279404390442, 0.512831, 0.148179, 0.507648, 0.5850537945728308, 0.519045, 0.150383, 0.507443, 0.5876803183965266, 0.52527, 0.152569, 0.507192, 0.5903061725303131, 0.531507, 0.154739, 0.506895, 0.592932696354009, 0.537755, 0.156894, 0.506551, 0.5955585504877956, 0.544015, 0.159033, 0.506159, 0.5981850743114914, 0.550287, 0.161158, 0.505719, 0.6008115981351871, 0.556571, 0.163269, 0.50523, 0.6034374522689737, 0.562866, 0.165368, 0.504692, 0.6060639760926695, 0.569172, 0.167454, 0.504105, 0.6086898302264562, 0.57549, 0.16953, 0.503466, 0.6113163540501519, 0.581819, 0.171596, 0.502777, 0.6139422081839385, 0.588158, 0.173652, 0.502035, 0.6165687320076343, 0.594508, 0.175701, 0.501241, 0.6191952558313301, 0.600868, 0.177743, 0.500394, 0.6218211099651167, 0.607238, 0.179779, 0.499492, 0.6244476337888125, 0.613617, 0.181811, 0.498536, 0.6270734879225992, 0.620005, 0.18384, 0.497524, 0.6297000117462948, 0.626401, 0.185867, 0.496456, 0.6323258658800814, 0.632805, 0.187893, 0.495332, 0.6349523897037772, 0.639216, 0.189921, 0.49415, 0.637578913527473, 0.645633, 0.191952, 0.49291, 0.6402047676612597, 0.652056, 0.193986, 0.491611, 0.6428312914849554, 0.658483, 0.196027, 0.490253, 0.6454571456187421, 0.664915, 0.198075, 0.488836, 0.6480836694424379, 0.671349, 0.200133, 0.487358, 0.6507095235762246, 0.677786, 0.202203, 0.485819, 0.6533360473999203, 0.684224, 0.204286, 0.484219, 0.6559625712236161, 0.690661, 0.206384, 0.482558, 0.6585884253574028, 0.697098, 0.208501, 0.480835, 0.6612149491810986, 0.703532, 0.210638, 0.479049, 0.663840803314885, 0.709962, 0.212797, 0.477201, 0.6664673271385809, 0.716387, 0.214982, 0.47529, 0.6690931812723676, 0.722805, 0.217194, 0.473316, 0.6717197050960633, 0.729216, 0.219437, 0.471279, 0.67434555922985, 0.735616, 0.221713, 0.46918, 0.6769720830535457, 0.742004, 0.224025, 0.467018, 0.6795986068772415, 0.748378, 0.226377, 0.464794, 0.6822244610110281, 0.754737, 0.228772, 0.462509, 0.6848509848347238, 0.761077, 0.231214, 0.460162, 0.6874768389685104, 0.767398, 0.233705, 0.457755, 0.6901033627922063, 0.773695, 0.236249, 0.455289, 0.6927292169259929, 0.779968, 0.238851, 0.452765, 0.6953557407496885, 0.786212, 0.241514, 0.450184, 0.6979822645733844, 0.792427, 0.244242, 0.447543, 0.7006081187071711, 0.798608, 0.24704, 0.444848, 0.7032346425308668, 0.804752, 0.249911, 0.442102, 0.7058604966646533, 0.810855, 0.252861, 0.439305, 0.7084870204883493, 0.816914, 0.255895, 0.436461, 0.7111128746221358, 0.822926, 0.259016, 0.433573, 0.7137393984458316, 0.828886, 0.262229, 0.430644, 0.7163659222695273, 0.834791, 0.26554, 0.427671, 0.718991776403314, 0.840636, 0.268953, 0.424666, 0.7216183002270098, 0.846416, 0.272473, 0.421631, 0.7242441543607965, 0.852126, 0.276106, 0.418573, 0.7268706781844922, 0.857763, 0.279857, 0.415496, 0.7294965323182787, 0.86332, 0.283729, 0.412403, 0.7321230561419747, 0.868793, 0.287728, 0.409303, 0.7347495799656703, 0.874176, 0.291859, 0.406205, 0.7373754340994569, 0.879464, 0.296125, 0.403118, 0.7400019579231529, 0.884651, 0.30053, 0.400047, 0.7426278120569394, 0.889731, 0.305079, 0.397002, 0.7452543358806352, 0.8947, 0.309773, 0.393995, 0.7478801900144219, 0.899552, 0.314616, 0.391037, 0.7505067138381176, 0.904281, 0.31961, 0.388137, 0.7531332376618134, 0.908884, 0.324755, 0.385308, 0.7557590917956001, 0.913354, 0.330052, 0.382563, 0.7583856156192957, 0.917689, 0.3355, 0.379915, 0.7610114697530823, 0.921884, 0.341098, 0.377376, 0.7636379935767782, 0.925937, 0.346844, 0.374959, 0.7662638477105649, 0.929845, 0.352734, 0.372677, 0.7688903715342605, 0.933606, 0.358764, 0.370541, 0.7715168953579563, 0.937221, 0.364929, 0.368567, 0.774142749491743, 0.940687, 0.371224, 0.366762, 0.7767692733154387, 0.944006, 0.377643, 0.365136, 0.7793951274492253, 0.94718, 0.384178, 0.363701, 0.7820216512729212, 0.95021, 0.39082, 0.362468, 0.7846475054067077, 0.953099, 0.397563, 0.361438, 0.7872740292304035, 0.955849, 0.4044, 0.360619, 0.7899005530540992, 0.958464, 0.411324, 0.360014, 0.7925264071878859, 0.960949, 0.418323, 0.35963, 0.7951529310115817, 0.96331, 0.42539, 0.359469, 0.7977787851453684, 0.965549, 0.432519, 0.359529, 0.8004053089690639, 0.967671, 0.439703, 0.35981, 0.8030311631028506, 0.96968, 0.446936, 0.360311, 0.8056576869265466, 0.971582, 0.45421, 0.36103, 0.8082835410603333, 0.973381, 0.46152, 0.361965, 0.8109100648840288, 0.975082, 0.468861, 0.363111, 0.8135365887077248, 0.97669, 0.476226, 0.364466, 0.8161624428415113, 0.97821, 0.483612, 0.366025, 0.8187889666652071, 0.979645, 0.491014, 0.367783, 0.8214148207989938, 0.981, 0.498428, 0.369734, 0.8240413446226895, 0.982279, 0.505851, 0.371874, 0.826667198756476, 0.983485, 0.51328, 0.374198, 0.829293722580172, 0.984622, 0.520713, 0.376698, 0.8319202464038677, 0.985693, 0.528148, 0.379371, 0.8345461005376542, 0.9867, 0.535582, 0.38221, 0.8371726243613502, 0.987646, 0.543015, 0.38521, 0.8397984784951367, 0.988533, 0.550446, 0.388365, 0.8424250023188324, 0.989363, 0.557873, 0.391671, 0.8450508564526191, 0.990138, 0.565296, 0.395122, 0.8476773802763149, 0.990871, 0.572706, 0.398714, 0.8503039041000107, 0.991558, 0.580107, 0.402441, 0.8529297582337974, 0.992196, 0.587502, 0.406299, 0.8555562820574931, 0.992785, 0.594891, 0.410283, 0.8581821361912796, 0.993326, 0.602275, 0.41439, 0.8608086600149754, 0.993834, 0.609644, 0.418613, 0.863434514148762, 0.994309, 0.616999, 0.42295, 0.8660610379724578, 0.994738, 0.62435, 0.427397, 0.8686875617961536, 0.995122, 0.631696, 0.431951, 0.8713134159299403, 0.99548, 0.639027, 0.436607, 0.8739399397536358, 0.99581, 0.646344, 0.441361, 0.8765657938874225, 0.996096, 0.653659, 0.446213, 0.8791923177111185, 0.996341, 0.660969, 0.45116, 0.881818171844905, 0.99658, 0.668256, 0.456192, 0.8844446956686007, 0.996775, 0.675541, 0.461314, 0.8870712194922967, 0.996925, 0.682828, 0.466526, 0.8896970736260832, 0.997077, 0.690088, 0.471811, 0.892323597449779, 0.997186, 0.697349, 0.477182, 0.8949494515835656, 0.997254, 0.704611, 0.482635, 0.8975759754072614, 0.997325, 0.711848, 0.488154, 0.9002018295410479, 0.997351, 0.719089, 0.493755, 0.9028283533647439, 0.997351, 0.726324, 0.499428, 0.9054548771884396, 0.997341, 0.733545, 0.505167, 0.9080807313222261, 0.997285, 0.740772, 0.510983, 0.9107072551459221, 0.997228, 0.747981, 0.516859, 0.9133331092797088, 0.997138, 0.75519, 0.522806, 0.9159596331034043, 0.997019, 0.762398, 0.528821, 0.918585487237191, 0.996898, 0.769591, 0.534892, 0.9212120110608868, 0.996727, 0.776795, 0.541039, 0.9238385348845826, 0.996571, 0.783977, 0.547233, 0.9264643890183692, 0.996369, 0.791167, 0.553499, 0.929090912842065, 0.996162, 0.798348, 0.55982, 0.9317167669758517, 0.995932, 0.805527, 0.566202, 0.9343432907995475, 0.99568, 0.812706, 0.572645, 0.9369691449333339, 0.995424, 0.819875, 0.57914, 0.9395956687570297, 0.995131, 0.827052, 0.585701, 0.9422215228908164, 0.994851, 0.834213, 0.592307, 0.9448480467145122, 0.994524, 0.841387, 0.598983, 0.9474745705382079, 0.994222, 0.84854, 0.605696, 0.9501004246719944, 0.993866, 0.855711, 0.612482, 0.9527269484956904, 0.993545, 0.862859, 0.619299, 0.9553528026294769, 0.99317, 0.870024, 0.626189, 0.9579793264531726, 0.992831, 0.877168, 0.633109, 0.9606051805869593, 0.99244, 0.88433, 0.640099, 0.9632317044106551, 0.992089, 0.89147, 0.647116, 0.9658582282343509, 0.991688, 0.898627, 0.654202, 0.9684840823681375, 0.991332, 0.905763, 0.661309, 0.9711106061918333, 0.99093, 0.912915, 0.668481, 0.9737364603256198, 0.99057, 0.920049, 0.675675, 0.9763629841493158, 0.990175, 0.927196, 0.682926, 0.9789888382831025, 0.989815, 0.934329, 0.690198, 0.981615362106798, 0.989434, 0.94147, 0.697519, 0.984241885930494, 0.989077, 0.948604, 0.704863, 0.9868677400642807, 0.988717, 0.955742, 0.712242, 0.9894942638879762, 0.988367, 0.962878, 0.719649, 0.9921201180217629, 0.988033, 0.970012, 0.727077, 0.9947466418454587, 0.987691, 0.977154, 0.734536, 0.9973724959792454, 0.987387, 0.984288, 0.742002, 0.9999990198029411, 0.987053, 0.991438, 0.749504]
elasticRatioLUT.ColorSpace = 'RGB'
elasticRatioLUT.NanColor = [0.0, 1.0, 0.0]
elasticRatioLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'elasticRatio'
elasticRatioPWF = GetOpacityTransferFunction('elasticRatio')
elasticRatioPWF.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
elasticRatioPWF.ScalarRangeInitialized = 1
# trace defaults for the display properties.
elasticRatiovtsDisplay.Representation = 'Surface'
elasticRatiovtsDisplay.ColorArrayName = ['POINTS', 'elasticRatio']
elasticRatiovtsDisplay.LookupTable = elasticRatioLUT
elasticRatiovtsDisplay.OSPRayScaleArray = 'elasticRatio'
elasticRatiovtsDisplay.OSPRayScaleFunction = 'PiecewiseFunction'
elasticRatiovtsDisplay.SelectOrientationVectors = 'None'
elasticRatiovtsDisplay.ScaleFactor = 0.9
elasticRatiovtsDisplay.SelectScaleArray = 'elasticRatio'
elasticRatiovtsDisplay.GlyphType = 'Arrow'
elasticRatiovtsDisplay.GlyphTableIndexArray = 'elasticRatio'
elasticRatiovtsDisplay.GaussianRadius = 0.045
elasticRatiovtsDisplay.SetScaleArray = ['POINTS', 'elasticRatio']
elasticRatiovtsDisplay.ScaleTransferFunction = 'PiecewiseFunction'
elasticRatiovtsDisplay.OpacityArray = ['POINTS', 'elasticRatio']
elasticRatiovtsDisplay.OpacityTransferFunction = 'PiecewiseFunction'
elasticRatiovtsDisplay.DataAxesGrid = 'GridAxesRepresentation'
elasticRatiovtsDisplay.PolarAxes = 'PolarAxesRepresentation'
elasticRatiovtsDisplay.ScalarOpacityFunction = elasticRatioPWF
elasticRatiovtsDisplay.ScalarOpacityUnitDistance = 0.24673084980136809
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
elasticRatiovtsDisplay.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
elasticRatiovtsDisplay.ScaleTransferFunction.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
elasticRatiovtsDisplay.OpacityTransferFunction.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
# reset view to fit data
renderView1.ResetCamera()
#changing interaction mode based on data extents
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [9999.5, 5.51, 0.5]
renderView1.CameraFocalPoint = [-0.5, 5.51, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
# show color bar/color legend
elasticRatiovtsDisplay.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# create a new 'Transform'
transform1 = Transform(Input=elasticRatiovts)
transform1.Transform = 'Transform'
# Properties modified on transform1.Transform
transform1.Transform.Scale = [1.0, 0.1, 1.0]
# show data in view
transform1Display = Show(transform1, renderView1)
# trace defaults for the display properties.
transform1Display.Representation = 'Surface'
transform1Display.ColorArrayName = ['POINTS', 'elasticRatio']
transform1Display.LookupTable = elasticRatioLUT
transform1Display.OSPRayScaleArray = 'elasticRatio'
transform1Display.OSPRayScaleFunction = 'PiecewiseFunction'
transform1Display.SelectOrientationVectors = 'None'
transform1Display.ScaleFactor = 0.098
transform1Display.SelectScaleArray = 'elasticRatio'
transform1Display.GlyphType = 'Arrow'
transform1Display.GlyphTableIndexArray = 'elasticRatio'
transform1Display.GaussianRadius = 0.0049
transform1Display.SetScaleArray = ['POINTS', 'elasticRatio']
transform1Display.ScaleTransferFunction = 'PiecewiseFunction'
transform1Display.OpacityArray = ['POINTS', 'elasticRatio']
transform1Display.OpacityTransferFunction = 'PiecewiseFunction'
transform1Display.DataAxesGrid = 'GridAxesRepresentation'
transform1Display.PolarAxes = 'PolarAxesRepresentation'
transform1Display.ScalarOpacityFunction = elasticRatioPWF
transform1Display.ScalarOpacityUnitDistance = 0.03626244811262771
# init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction'
transform1Display.OSPRayScaleFunction.Points = [1.0, 0.8602941036224365, 0.5, 0.0, 1.213836476688135, 0.625, 0.5, 0.0, 1.3616352081298828, 0.6691176295280457, 0.5, 0.0, 1.6666333299996667, 0.8676470518112183, 0.5, 0.0, 1.7358490228652954, 0.6911764740943909, 0.5, 0.0, 2.0, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'ScaleTransferFunction'
transform1Display.ScaleTransferFunction.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
# init the 'PiecewiseFunction' selected for 'OpacityTransferFunction'
transform1Display.OpacityTransferFunction.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
# hide data in view
Hide(elasticRatiovts, renderView1)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# reset view to fit data
renderView1.ResetCamera()
# reset view to fit data
renderView1.ResetCamera()
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=transform1.Transform)
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
elasticRatioLUT.ApplyPreset('Warm to Cool (Extended)', True)
# change representation type
transform1Display.SetRepresentationType('Point Gaussian')
# Properties modified on transform1Display
transform1Display.ShaderPreset = 'Plain circle'
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.Visibility = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.XTitle = ''
renderView1.AxesGrid.ZTitle = ' $\\theta$ '
renderView1.AxesGrid.YTitle = ' $\\theta_\\mu$ '
renderView1.AxesGrid.ZTitleFontSize = 20
renderView1.AxesGrid.YTitleFontSize = 20
renderView1.AxesGrid.FacesToRender = 0
renderView1.AxesGrid.CullFrontface = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.FacesToRender = 32
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.FacesToRender = 16
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.FacesToRender = 4
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.FacesToRender = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowEdges = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowTicks = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ShowGrid = 1
renderView1.AxesGrid.GridColor = [0.1803921568627451, 0.20392156862745098, 0.21176470588235294]
# Properties modified on renderView1.AxesGrid
# renderView1.AxesGrid.ShowGrid = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.AxesToLabel = 7
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.DataScale = [1.0, 0.1, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.YAxisUseCustomLabels = 1
renderView1.AxesGrid.YAxisLabels = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisUseCustomLabels = 1
renderView1.AxesGrid.ZAxisLabels = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisLabels = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.ZAxisLabels = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
#### saving camera placements for all active views
# current camera placement for renderView1
renderView1.InteractionMode = '2D'
renderView1.CameraPosition = [2.0704518571099406, 0.551, 0.5]
renderView1.CameraFocalPoint = [-0.5, 0.551, 0.5]
renderView1.CameraViewUp = [0.0, 0.0, 1.0]
renderView1.CameraParallelScale = 0.6652818951391959
renderView1.AxesGrid.YTitleFontSize = 65 #24
renderView1.AxesGrid.ZTitleFontSize = 65
renderView1.AxesGrid.YLabelFontSize = 45 #default:12
renderView1.AxesGrid.ZLabelFontSize = 45
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
# --------------------------------------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------------------------------------
if case == 1: #prestrain
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'prestrainRatio'))
# get color transfer function/color map for 'prestrainRatio'
prestrainRatioLUT = GetColorTransferFunction('prestrainRatio')
prestrainRatioLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
prestrainRatioLUT.InterpretValuesAsCategories = 0
prestrainRatioLUT.AnnotationsInitialized = 0
prestrainRatioLUT.ShowCategoricalColorsinDataRangeOnly = 0
prestrainRatioLUT.RescaleOnVisibilityChange = 0
prestrainRatioLUT.EnableOpacityMapping = 0
prestrainRatioLUT.RGBPoints = [1.0000497462439073, 0.001462, 0.000466, 0.013866, 1.0017355871052882, 0.002258, 0.001295, 0.018331, 1.0034209981245321, 0.003279, 0.002305, 0.023708, 1.005106838985913, 0.004512, 0.00349, 0.029965, 1.006792250005157, 0.00595, 0.004843, 0.03713, 1.008478090866538, 0.007588, 0.006356, 0.044973, 1.0101635018857817, 0.009426, 0.008022, 0.052844, 1.0118493427471627, 0.011465, 0.009828, 0.06075, 1.0135351836085438, 0.013708, 0.011771, 0.068667, 1.0152205946277877, 0.016156, 0.01384, 0.076603, 1.0169064354891686, 0.018815, 0.016026, 0.084584, 1.0185918465084125, 0.021692, 0.01832, 0.09261, 1.0202776873697934, 0.024792, 0.020715, 0.100676, 1.0219630983890373, 0.028123, 0.023201, 0.108787, 1.0236489392504182, 0.031696, 0.025765, 0.116965, 1.0253347801117991, 0.03552, 0.028397, 0.125209, 1.027020191131043, 0.039608, 0.03109, 0.133515, 1.028706031992424, 0.04383, 0.03383, 0.141886, 1.030391443011668, 0.048062, 0.036607, 0.150327, 1.032077283873049, 0.05232, 0.039407, 0.158841, 1.0337626948922927, 0.056615, 0.04216, 0.167446, 1.0354485357536738, 0.060949, 0.044794, 0.176129, 1.0371343766150547, 0.06533, 0.047318, 0.184892, 1.0388197876342986, 0.069764, 0.049726, 0.193735, 1.0405056284956795, 0.074257, 0.052017, 0.20266, 1.0421910395149234, 0.078815, 0.054184, 0.211667, 1.0438768803763043, 0.083446, 0.056225, 0.220755, 1.0455622913955482, 0.088155, 0.058133, 0.229922, 1.0472481322569291, 0.092949, 0.059904, 0.239164, 1.0489335432761733, 0.097833, 0.061531, 0.248477, 1.0506193841375542, 0.102815, 0.06301, 0.257854, 1.052305224998935, 0.107899, 0.064335, 0.267289, 1.053990636018179, 0.113094, 0.065492, 0.276784, 1.05567647687956, 0.118405, 0.066479, 0.286321, 1.0573618878988038, 0.123833, 0.067295, 0.295879, 1.0590477287601847, 0.12938, 0.067935, 0.305443, 1.0607331397794286, 0.135053, 0.068391, 0.315, 1.0624189806408095, 0.140858, 0.068654, 0.324538, 1.0641048215021904, 0.146785, 0.068738, 0.334011, 1.0657902325214343, 0.152839, 0.068637, 0.343404, 1.0674760733828152, 0.159018, 0.068354, 0.352688, 1.0691614844020592, 0.165308, 0.067911, 0.361816, 1.0708473252634403, 0.171713, 0.067305, 0.370771, 1.0725327362826842, 0.178212, 0.066576, 0.379497, 1.074218577144065, 0.184801, 0.065732, 0.387973, 1.075904418005446, 0.19146, 0.064818, 0.396152, 1.07758982902469, 0.198177, 0.063862, 0.404009, 1.0792756698860708, 0.204935, 0.062907, 0.411514, 1.0809610809053147, 0.211718, 0.061992, 0.418647, 1.0826469217666956, 0.218512, 0.061158, 0.425392, 1.0843323327859395, 0.225302, 0.060445, 0.431742, 1.0860181736473205, 0.232077, 0.059889, 0.437695, 1.0877040145087014, 0.238826, 0.059517, 0.443256, 1.0893894255279453, 0.245543, 0.059352, 0.448436, 1.0910752663893262, 0.25222, 0.059415, 0.453248, 1.0927606774085703, 0.258857, 0.059706, 0.45771, 1.0944465182699512, 0.265447, 0.060237, 0.46184, 1.0961319292891951, 0.271994, 0.060994, 0.46566, 1.097817770150576, 0.278493, 0.061978, 0.46919, 1.099503611011957, 0.284951, 0.063168, 0.472451, 1.1011890220312008, 0.291366, 0.064553, 0.475462, 1.1028748628925817, 0.29774, 0.066117, 0.478243, 1.1045602739118257, 0.304081, 0.067835, 0.480812, 1.1062461147732066, 0.310382, 0.069702, 0.483186, 1.1079315257924505, 0.316654, 0.07169, 0.48538, 1.1096173666538314, 0.322899, 0.073782, 0.487408, 1.1113032075152123, 0.329114, 0.075972, 0.489287, 1.1129886185344562, 0.335308, 0.078236, 0.491024, 1.1146744593958373, 0.341482, 0.080564, 0.492631, 1.1163598704150812, 0.347636, 0.082946, 0.494121, 1.1180457112764621, 0.353773, 0.085373, 0.495501, 1.119731122295706, 0.359898, 0.087831, 0.496778, 1.121416963157087, 0.366012, 0.090314, 0.49796, 1.1231028040184678, 0.372116, 0.092816, 0.499053, 1.1247882150377118, 0.378211, 0.095332, 0.500067, 1.1264740558990927, 0.384299, 0.097855, 0.501002, 1.1281594669183366, 0.390384, 0.100379, 0.501864, 1.1298453077797175, 0.396467, 0.102902, 0.502658, 1.1315307187989614, 0.402548, 0.10542, 0.503386, 1.1332165596603425, 0.408629, 0.10793, 0.504052, 1.1349019706795864, 0.414709, 0.110431, 0.504662, 1.1365878115409673, 0.420791, 0.11292, 0.505215, 1.1382736524023482, 0.426877, 0.115395, 0.505714, 1.1399590634215921, 0.432967, 0.117855, 0.50616, 1.141644904282973, 0.439062, 0.120298, 0.506555, 1.143330315302217, 0.445163, 0.122724, 0.506901, 1.1450161561635979, 0.451271, 0.125132, 0.507198, 1.1467015671828418, 0.457386, 0.127522, 0.507448, 1.148387408044223, 0.463508, 0.129893, 0.507652, 1.1500732489056036, 0.46964, 0.132245, 0.507809, 1.1517586599248475, 0.47578, 0.134577, 0.507921, 1.1534445007862284, 0.481929, 0.136891, 0.507989, 1.1551299118054725, 0.488088, 0.139186, 0.508011, 1.1568157526668534, 0.494258, 0.141462, 0.507988, 1.1585011636860973, 0.500438, 0.143719, 0.50792, 1.1601870045474783, 0.506629, 0.145958, 0.507806, 1.1618728454088592, 0.512831, 0.148179, 0.507648, 1.163558256428103, 0.519045, 0.150383, 0.507443, 1.165244097289484, 0.52527, 0.152569, 0.507192, 1.1669295083087279, 0.531507, 0.154739, 0.506895, 1.1686153491701088, 0.537755, 0.156894, 0.506551, 1.1703007601893527, 0.544015, 0.159033, 0.506159, 1.1719866010507336, 0.550287, 0.161158, 0.505719, 1.1736724419121147, 0.556571, 0.163269, 0.50523, 1.1753578529313584, 0.562866, 0.165368, 0.504692, 1.1770436937927395, 0.569172, 0.167454, 0.504105, 1.1787291048119835, 0.57549, 0.16953, 0.503466, 1.1804149456733644, 0.581819, 0.171596, 0.502777, 1.1821003566926083, 0.588158, 0.173652, 0.502035, 1.1837861975539892, 0.594508, 0.175701, 0.501241, 1.18547203841537, 0.600868, 0.177743, 0.500394, 1.187157449434614, 0.607238, 0.179779, 0.499492, 1.188843290295995, 0.613617, 0.181811, 0.498536, 1.1905287013152388, 0.620005, 0.18384, 0.497524, 1.1922145421766197, 0.626401, 0.185867, 0.496456, 1.1938999531958636, 0.632805, 0.187893, 0.495332, 1.1955857940572445, 0.639216, 0.189921, 0.49415, 1.1972716349186254, 0.645633, 0.191952, 0.49291, 1.1989570459378696, 0.652056, 0.193986, 0.491611, 1.2006428867992505, 0.658483, 0.196027, 0.490253, 1.2023282978184944, 0.664915, 0.198075, 0.488836, 1.2040141386798753, 0.671349, 0.200133, 0.487358, 1.2056995496991192, 0.677786, 0.202203, 0.485819, 1.2073853905605, 0.684224, 0.204286, 0.484219, 1.209071231421881, 0.690661, 0.206384, 0.482558, 1.210756642441125, 0.697098, 0.208501, 0.480835, 1.2124424833025058, 0.703532, 0.210638, 0.479049, 1.2141278943217497, 0.709962, 0.212797, 0.477201, 1.2158137351831309, 0.716387, 0.214982, 0.47529, 1.2174991462023748, 0.722805, 0.217194, 0.473316, 1.2191849870637557, 0.729216, 0.219437, 0.471279, 1.2208703980829996, 0.735616, 0.221713, 0.46918, 1.2225562389443805, 0.742004, 0.224025, 0.467018, 1.2242420798057614, 0.748378, 0.226377, 0.464794, 1.2259274908250053, 0.754737, 0.228772, 0.462509, 1.2276133316863862, 0.761077, 0.231214, 0.460162, 1.22929874270563, 0.767398, 0.233705, 0.457755, 1.230984583567011, 0.773695, 0.236249, 0.455289, 1.2326699945862551, 0.779968, 0.238851, 0.452765, 1.2343558354476358, 0.786212, 0.241514, 0.450184, 1.236041676309017, 0.792427, 0.244242, 0.447543, 1.2377270873282609, 0.798608, 0.24704, 0.444848, 1.2394129281896418, 0.804752, 0.249911, 0.442102, 1.2410983392088857, 0.810855, 0.252861, 0.439305, 1.2427841800702666, 0.816914, 0.255895, 0.436461, 1.2444695910895105, 0.822926, 0.259016, 0.433573, 1.2461554319508914, 0.828886, 0.262229, 0.430644, 1.2478412728122723, 0.834791, 0.26554, 0.427671, 1.2495266838315162, 0.840636, 0.268953, 0.424666, 1.2512125246928971, 0.846416, 0.272473, 0.421631, 1.252897935712141, 0.852126, 0.276106, 0.418573, 1.2545837765735222, 0.857763, 0.279857, 0.415496, 1.2562691875927658, 0.86332, 0.283729, 0.412403, 1.257955028454147, 0.868793, 0.287728, 0.409303, 1.2596408693155277, 0.874176, 0.291859, 0.406205, 1.2613262803347718, 0.879464, 0.296125, 0.403118, 1.2630121211961527, 0.884651, 0.30053, 0.400047, 1.2646975322153966, 0.889731, 0.305079, 0.397002, 1.2663833730767775, 0.8947, 0.309773, 0.393995, 1.2680687840960214, 0.899552, 0.314616, 0.391037, 1.2697546249574023, 0.904281, 0.31961, 0.388137, 1.2714404658187832, 0.908884, 0.324755, 0.385308, 1.2731258768380274, 0.913354, 0.330052, 0.382563, 1.274811717699408, 0.917689, 0.3355, 0.379915, 1.276497128718652, 0.921884, 0.341098, 0.377376, 1.278182969580033, 0.925937, 0.346844, 0.374959, 1.279868380599277, 0.929845, 0.352734, 0.372677, 1.2815542214606577, 0.933606, 0.358764, 0.370541, 1.2832400623220388, 0.937221, 0.364929, 0.368567, 1.2849254733412827, 0.940687, 0.371224, 0.366762, 1.2866113142026636, 0.944006, 0.377643, 0.365136, 1.2882967252219075, 0.94718, 0.384178, 0.363701, 1.2899825660832884, 0.95021, 0.39082, 0.362468, 1.2916679771025323, 0.953099, 0.397563, 0.361438, 1.2933538179639132, 0.955849, 0.4044, 0.360619, 1.2950396588252944, 0.958464, 0.411324, 0.360014, 1.296725069844538, 0.960949, 0.418323, 0.35963, 1.2984109107059192, 0.96331, 0.42539, 0.359469, 1.300096321725163, 0.965549, 0.432519, 0.359529, 1.301782162586544, 0.967671, 0.439703, 0.35981, 1.3034675736057877, 0.96968, 0.446936, 0.360311, 1.3051534144671688, 0.971582, 0.45421, 0.36103, 1.3068388254864127, 0.973381, 0.46152, 0.361965, 1.3085246663477936, 0.975082, 0.468861, 0.363111, 1.3102105072091748, 0.97669, 0.476226, 0.364466, 1.3118959182284184, 0.97821, 0.483612, 0.366025, 1.3135817590897994, 0.979645, 0.491014, 0.367783, 1.3152671701090433, 0.981, 0.498428, 0.369734, 1.3169530109704244, 0.982279, 0.505851, 0.371874, 1.318638421989668, 0.983485, 0.51328, 0.374198, 1.3203242628510492, 0.984622, 0.520713, 0.376698, 1.32201010371243, 0.985693, 0.528148, 0.379371, 1.323695514731674, 0.9867, 0.535582, 0.38221, 1.325381355593055, 0.987646, 0.543015, 0.38521, 1.3270667666122988, 0.988533, 0.550446, 0.388365, 1.3287526074736797, 0.989363, 0.557873, 0.391671, 1.3304380184929236, 0.990138, 0.565296, 0.395122, 1.3321238593543048, 0.990871, 0.572706, 0.398714, 1.3338097002156855, 0.991558, 0.580107, 0.402441, 1.3354951112349294, 0.992196, 0.587502, 0.406299, 1.3371809520963103, 0.992785, 0.594891, 0.410283, 1.3388663631155544, 0.993326, 0.602275, 0.41439, 1.3405522039769353, 0.993834, 0.609644, 0.418613, 1.3422376149961792, 0.994309, 0.616999, 0.42295, 1.3439234558575601, 0.994738, 0.62435, 0.427397, 1.345609296718941, 0.995122, 0.631696, 0.431951, 1.347294707738185, 0.99548, 0.639027, 0.436607, 1.3489805485995658, 0.99581, 0.646344, 0.441361, 1.3506659596188098, 0.996096, 0.653659, 0.446213, 1.3523518004801907, 0.996341, 0.660969, 0.45116, 1.3540372114994346, 0.99658, 0.668256, 0.456192, 1.3557230523608155, 0.996775, 0.675541, 0.461314, 1.3574088932221966, 0.996925, 0.682828, 0.466526, 1.3590943042414403, 0.997077, 0.690088, 0.471811, 1.3607801451028214, 0.997186, 0.697349, 0.477182, 1.3624655561220653, 0.997254, 0.704611, 0.482635, 1.3641513969834462, 0.997325, 0.711848, 0.488154, 1.36583680800269, 0.997351, 0.719089, 0.493755, 1.367522648864071, 0.997351, 0.726324, 0.499428, 1.369208489725452, 0.997341, 0.733545, 0.505167, 1.3708939007446959, 0.997285, 0.740772, 0.510983, 1.372579741606077, 0.997228, 0.747981, 0.516859, 1.3742651526253207, 0.997138, 0.75519, 0.522806, 1.3759509934867016, 0.997019, 0.762398, 0.528821, 1.3776364045059455, 0.996898, 0.769591, 0.534892, 1.3793222453673266, 0.996727, 0.776795, 0.541039, 1.3810080862287073, 0.996571, 0.783977, 0.547233, 1.3826934972479514, 0.996369, 0.791167, 0.553499, 1.3843793381093323, 0.996162, 0.798348, 0.55982, 1.3860647491285762, 0.995932, 0.805527, 0.566202, 1.3877505899899572, 0.99568, 0.812706, 0.572645, 1.389436001009201, 0.995424, 0.819875, 0.57914, 1.391121841870582, 0.995131, 0.827052, 0.585701, 1.3928072528898259, 0.994851, 0.834213, 0.592307, 1.394493093751207, 0.994524, 0.841387, 0.598983, 1.3961789346125877, 0.994222, 0.84854, 0.605696, 1.3978643456318316, 0.993866, 0.855711, 0.612482, 1.3995501864932127, 0.993545, 0.862859, 0.619299, 1.4012355975124566, 0.99317, 0.870024, 0.626189, 1.4029214383738373, 0.992831, 0.877168, 0.633109, 1.4046068493930814, 0.99244, 0.88433, 0.640099, 1.4062926902544624, 0.992089, 0.89147, 0.647116, 1.4079785311158433, 0.991688, 0.898627, 0.654202, 1.4096639421350872, 0.991332, 0.905763, 0.661309, 1.411349782996468, 0.99093, 0.912915, 0.668481, 1.413035194015712, 0.99057, 0.920049, 0.675675, 1.4147210348770929, 0.990175, 0.927196, 0.682926, 1.416406445896337, 0.989815, 0.934329, 0.690198, 1.4180922867577177, 0.989434, 0.94147, 0.697519, 1.4197781276190988, 0.989077, 0.948604, 0.704863, 1.4214635386383427, 0.988717, 0.955742, 0.712242, 1.4231493794997236, 0.988367, 0.962878, 0.719649, 1.4248347905189676, 0.988033, 0.970012, 0.727077, 1.4265206313803485, 0.987691, 0.977154, 0.734536, 1.4282060423995924, 0.987387, 0.984288, 0.742002, 1.4298918832609733, 0.987053, 0.991438, 0.749504]
prestrainRatioLUT.UseLogScale = 0
prestrainRatioLUT.ColorSpace = 'RGB'
prestrainRatioLUT.UseBelowRangeColor = 0
prestrainRatioLUT.BelowRangeColor = [0.0, 0.0, 0.0]
prestrainRatioLUT.UseAboveRangeColor = 0
prestrainRatioLUT.AboveRangeColor = [0.5, 0.5, 0.5]
prestrainRatioLUT.NanColor = [0.0, 1.0, 0.0]
prestrainRatioLUT.NanOpacity = 1.0
prestrainRatioLUT.Discretize = 1
prestrainRatioLUT.NumberOfTableValues = 256
prestrainRatioLUT.ScalarRangeInitialized = 1.0
prestrainRatioLUT.HSVWrap = 0
prestrainRatioLUT.VectorComponent = 0
prestrainRatioLUT.VectorMode = 'Magnitude'
prestrainRatioLUT.AllowDuplicateScalars = 1
prestrainRatioLUT.Annotations = []
prestrainRatioLUT.ActiveAnnotatedValues = []
prestrainRatioLUT.IndexedColors = []
prestrainRatioLUT.IndexedOpacities = []
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
prestrainRatioLUT.ApplyPreset('Warm to Cool (Extended)', True)
# get opacity transfer function/opacity map for 'prestrainRatio'
prestrainRatioPWF = GetOpacityTransferFunction('prestrainRatio')
prestrainRatioPWF.Points = [1.0000497462439073, 0.8602941036224365, 0.5, 0.0, 1.0919656743557353, 0.625, 0.5, 0.0, 1.1554957969270676, 0.6691176295280457, 0.5, 0.0, 1.2865968414177669, 0.8676470518112183, 0.5, 0.0, 1.3163486627542458, 0.6911764740943909, 0.5, 0.0, 1.4298918832609733, 0.8014705777168274, 0.5, 0.0]
prestrainRatioPWF.AllowDuplicateScalars = 1
prestrainRatioPWF.UseLogScale = 0
prestrainRatioPWF.ScalarRangeInitialized = 1
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
prestrainRatioLUT.ApplyPreset('Warm to Cool (Extended)', True)
# invert the transfer function
prestrainRatioLUT.InvertTransferFunction()
# get active source.
transform1 = GetActiveSource()
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1067, 547]
# get display properties
transform1Display = GetDisplayProperties(transform1, view=renderView1)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# hide color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# hide color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, False)
# set scalar coloring using an separate color/opacity maps
ColorBy(transform1Display, ('POINTS', 'prestrainRatio'), True)
# get color transfer function/color map for 'prestrainRatio'
prestrainRatioLUT = GetColorTransferFunction('prestrainRatio')
prestrainRatioLUT.RGBPoints = [1.0000497462439073, 0.12549, 0.0, 0.380392, 1.010795799669334, 0.113725, 0.0235294, 0.45098, 1.0215418530947606, 0.105882, 0.0509804, 0.509804, 1.032287906520187, 0.0392157, 0.0392157, 0.560784, 1.043033959945614, 0.0313725, 0.0980392, 0.6, 1.0537800133710404, 0.0431373, 0.164706, 0.639216, 1.0645260667964673, 0.054902, 0.243137, 0.678431, 1.0752721202218938, 0.054902, 0.317647, 0.709804, 1.0860181736473205, 0.0509804, 0.396078, 0.741176, 1.0967642270727471, 0.0392157, 0.466667, 0.768627, 1.1075102804981738, 0.0313725, 0.537255, 0.788235, 1.1234423793067114, 0.0313725, 0.615686, 0.811765, 1.1369149214072372, 0.0235294, 0.709804, 0.831373, 1.1497461390393338, 0.0509804, 0.8, 0.85098, 1.1591553834186372, 0.0705882, 0.854902, 0.870588, 1.1694204434927418, 0.262745, 0.901961, 0.862745, 1.177332977550952, 0.423529, 0.941176, 0.87451, 1.187383976240822, 0.572549, 0.964706, 0.835294, 1.1948688173727002, 0.658824, 0.980392, 0.843137, 1.2014982726519143, 0.764706, 0.980392, 0.866667, 1.2079136665468941, 0.827451, 0.980392, 0.886275, 1.2145409726154233, 0.913725, 0.988235, 0.937255, 1.2149708147524403, 1.0, 1.0, 1.0, 1.2154006568894573, 0.988235, 0.980392, 0.870588, 1.2220279629579864, 0.992157, 0.964706, 0.713725, 1.2278020323845367, 0.988235, 0.956863, 0.643137, 1.2389224783113053, 0.980392, 0.917647, 0.509804, 1.2498288628538392, 0.968627, 0.87451, 0.407843, 1.2598798615437092, 0.94902, 0.823529, 0.321569, 1.2687010818795734, 0.929412, 0.776471, 0.278431, 1.2794471353050003, 0.909804, 0.717647, 0.235294, 1.2901931887304268, 0.890196, 0.658824, 0.196078, 1.3009392421558534, 0.878431, 0.619608, 0.168627, 1.31168529558128, 0.870588, 0.54902, 0.156863, 1.3224313490067068, 0.85098, 0.47451, 0.145098, 1.3331774024321335, 0.831373, 0.411765, 0.133333, 1.3439234558575601, 0.811765, 0.345098, 0.113725, 1.3546695092829868, 0.788235, 0.266667, 0.0941176, 1.3654155627084135, 0.741176, 0.184314, 0.0745098, 1.3761616161338401, 0.690196, 0.12549, 0.0627451, 1.3869076695592666, 0.619608, 0.0627451, 0.0431373, 1.3976537229846933, 0.54902, 0.027451, 0.0705882, 1.40839977641012, 0.470588, 0.0156863, 0.0901961, 1.4191458298355466, 0.4, 0.00392157, 0.101961, 1.4298918832609733, 0.34902, 0.0, 0.129412]
prestrainRatioLUT.ColorSpace = 'Lab'
prestrainRatioLUT.NanColor = [0.250004, 0.0, 0.0]
prestrainRatioLUT.ScalarRangeInitialized = 1.0
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(prestrainRatioLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
transform1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# get separate color transfer function/color map for 'prestrainRatio'
separate_transform1Display_prestrainRatioLUT = GetColorTransferFunction('prestrainRatio', transform1Display, separate=True)
separate_transform1Display_prestrainRatioLUT.RGBPoints = [1.0000497462439073, 0.001462, 0.000466, 0.013866, 1.0017355871052882, 0.002258, 0.001295, 0.018331, 1.0034209981245321, 0.003279, 0.002305, 0.023708, 1.005106838985913, 0.004512, 0.00349, 0.029965, 1.006792250005157, 0.00595, 0.004843, 0.03713, 1.008478090866538, 0.007588, 0.006356, 0.044973, 1.0101635018857817, 0.009426, 0.008022, 0.052844, 1.0118493427471627, 0.011465, 0.009828, 0.06075, 1.0135351836085438, 0.013708, 0.011771, 0.068667, 1.0152205946277877, 0.016156, 0.01384, 0.076603, 1.0169064354891686, 0.018815, 0.016026, 0.084584, 1.0185918465084125, 0.021692, 0.01832, 0.09261, 1.0202776873697934, 0.024792, 0.020715, 0.100676, 1.0219630983890373, 0.028123, 0.023201, 0.108787, 1.0236489392504182, 0.031696, 0.025765, 0.116965, 1.0253347801117991, 0.03552, 0.028397, 0.125209, 1.027020191131043, 0.039608, 0.03109, 0.133515, 1.028706031992424, 0.04383, 0.03383, 0.141886, 1.030391443011668, 0.048062, 0.036607, 0.150327, 1.032077283873049, 0.05232, 0.039407, 0.158841, 1.0337626948922927, 0.056615, 0.04216, 0.167446, 1.0354485357536738, 0.060949, 0.044794, 0.176129, 1.0371343766150547, 0.06533, 0.047318, 0.184892, 1.0388197876342986, 0.069764, 0.049726, 0.193735, 1.0405056284956795, 0.074257, 0.052017, 0.20266, 1.0421910395149234, 0.078815, 0.054184, 0.211667, 1.0438768803763043, 0.083446, 0.056225, 0.220755, 1.0455622913955482, 0.088155, 0.058133, 0.229922, 1.0472481322569291, 0.092949, 0.059904, 0.239164, 1.0489335432761733, 0.097833, 0.061531, 0.248477, 1.0506193841375542, 0.102815, 0.06301, 0.257854, 1.052305224998935, 0.107899, 0.064335, 0.267289, 1.053990636018179, 0.113094, 0.065492, 0.276784, 1.05567647687956, 0.118405, 0.066479, 0.286321, 1.0573618878988038, 0.123833, 0.067295, 0.295879, 1.0590477287601847, 0.12938, 0.067935, 0.305443, 1.0607331397794286, 0.135053, 0.068391, 0.315, 1.0624189806408095, 0.140858, 0.068654, 0.324538, 1.0641048215021904, 0.146785, 0.068738, 0.334011, 1.0657902325214343, 0.152839, 0.068637, 0.343404, 1.0674760733828152, 0.159018, 0.068354, 0.352688, 1.0691614844020592, 0.165308, 0.067911, 0.361816, 1.0708473252634403, 0.171713, 0.067305, 0.370771, 1.0725327362826842, 0.178212, 0.066576, 0.379497, 1.074218577144065, 0.184801, 0.065732, 0.387973, 1.075904418005446, 0.19146, 0.064818, 0.396152, 1.07758982902469, 0.198177, 0.063862, 0.404009, 1.0792756698860708, 0.204935, 0.062907, 0.411514, 1.0809610809053147, 0.211718, 0.061992, 0.418647, 1.0826469217666956, 0.218512, 0.061158, 0.425392, 1.0843323327859395, 0.225302, 0.060445, 0.431742, 1.0860181736473205, 0.232077, 0.059889, 0.437695, 1.0877040145087014, 0.238826, 0.059517, 0.443256, 1.0893894255279453, 0.245543, 0.059352, 0.448436, 1.0910752663893262, 0.25222, 0.059415, 0.453248, 1.0927606774085703, 0.258857, 0.059706, 0.45771, 1.0944465182699512, 0.265447, 0.060237, 0.46184, 1.0961319292891951, 0.271994, 0.060994, 0.46566, 1.097817770150576, 0.278493, 0.061978, 0.46919, 1.099503611011957, 0.284951, 0.063168, 0.472451, 1.1011890220312008, 0.291366, 0.064553, 0.475462, 1.1028748628925817, 0.29774, 0.066117, 0.478243, 1.1045602739118257, 0.304081, 0.067835, 0.480812, 1.1062461147732066, 0.310382, 0.069702, 0.483186, 1.1079315257924505, 0.316654, 0.07169, 0.48538, 1.1096173666538314, 0.322899, 0.073782, 0.487408, 1.1113032075152123, 0.329114, 0.075972, 0.489287, 1.1129886185344562, 0.335308, 0.078236, 0.491024, 1.1146744593958373, 0.341482, 0.080564, 0.492631, 1.1163598704150812, 0.347636, 0.082946, 0.494121, 1.1180457112764621, 0.353773, 0.085373, 0.495501, 1.119731122295706, 0.359898, 0.087831, 0.496778, 1.121416963157087, 0.366012, 0.090314, 0.49796, 1.1231028040184678, 0.372116, 0.092816, 0.499053, 1.1247882150377118, 0.378211, 0.095332, 0.500067, 1.1264740558990927, 0.384299, 0.097855, 0.501002, 1.1281594669183366, 0.390384, 0.100379, 0.501864, 1.1298453077797175, 0.396467, 0.102902, 0.502658, 1.1315307187989614, 0.402548, 0.10542, 0.503386, 1.1332165596603425, 0.408629, 0.10793, 0.504052, 1.1349019706795864, 0.414709, 0.110431, 0.504662, 1.1365878115409673, 0.420791, 0.11292, 0.505215, 1.1382736524023482, 0.426877, 0.115395, 0.505714, 1.1399590634215921, 0.432967, 0.117855, 0.50616, 1.141644904282973, 0.439062, 0.120298, 0.506555, 1.143330315302217, 0.445163, 0.122724, 0.506901, 1.1450161561635979, 0.451271, 0.125132, 0.507198, 1.1467015671828418, 0.457386, 0.127522, 0.507448, 1.148387408044223, 0.463508, 0.129893, 0.507652, 1.1500732489056036, 0.46964, 0.132245, 0.507809, 1.1517586599248475, 0.47578, 0.134577, 0.507921, 1.1534445007862284, 0.481929, 0.136891, 0.507989, 1.1551299118054725, 0.488088, 0.139186, 0.508011, 1.1568157526668534, 0.494258, 0.141462, 0.507988, 1.1585011636860973, 0.500438, 0.143719, 0.50792, 1.1601870045474783, 0.506629, 0.145958, 0.507806, 1.1618728454088592, 0.512831, 0.148179, 0.507648, 1.163558256428103, 0.519045, 0.150383, 0.507443, 1.165244097289484, 0.52527, 0.152569, 0.507192, 1.1669295083087279, 0.531507, 0.154739, 0.506895, 1.1686153491701088, 0.537755, 0.156894, 0.506551, 1.1703007601893527, 0.544015, 0.159033, 0.506159, 1.1719866010507336, 0.550287, 0.161158, 0.505719, 1.1736724419121147, 0.556571, 0.163269, 0.50523, 1.1753578529313584, 0.562866, 0.165368, 0.504692, 1.1770436937927395, 0.569172, 0.167454, 0.504105, 1.1787291048119835, 0.57549, 0.16953, 0.503466, 1.1804149456733644, 0.581819, 0.171596, 0.502777, 1.1821003566926083, 0.588158, 0.173652, 0.502035, 1.1837861975539892, 0.594508, 0.175701, 0.501241, 1.18547203841537, 0.600868, 0.177743, 0.500394, 1.187157449434614, 0.607238, 0.179779, 0.499492, 1.188843290295995, 0.613617, 0.181811, 0.498536, 1.1905287013152388, 0.620005, 0.18384, 0.497524, 1.1922145421766197, 0.626401, 0.185867, 0.496456, 1.1938999531958636, 0.632805, 0.187893, 0.495332, 1.1955857940572445, 0.639216, 0.189921, 0.49415, 1.1972716349186254, 0.645633, 0.191952, 0.49291, 1.1989570459378696, 0.652056, 0.193986, 0.491611, 1.2006428867992505, 0.658483, 0.196027, 0.490253, 1.2023282978184944, 0.664915, 0.198075, 0.488836, 1.2040141386798753, 0.671349, 0.200133, 0.487358, 1.2056995496991192, 0.677786, 0.202203, 0.485819, 1.2073853905605, 0.684224, 0.204286, 0.484219, 1.209071231421881, 0.690661, 0.206384, 0.482558, 1.210756642441125, 0.697098, 0.208501, 0.480835, 1.2124424833025058, 0.703532, 0.210638, 0.479049, 1.2141278943217497, 0.709962, 0.212797, 0.477201, 1.2158137351831309, 0.716387, 0.214982, 0.47529, 1.2174991462023748, 0.722805, 0.217194, 0.473316, 1.2191849870637557, 0.729216, 0.219437, 0.471279, 1.2208703980829996, 0.735616, 0.221713, 0.46918, 1.2225562389443805, 0.742004, 0.224025, 0.467018, 1.2242420798057614, 0.748378, 0.226377, 0.464794, 1.2259274908250053, 0.754737, 0.228772, 0.462509, 1.2276133316863862, 0.761077, 0.231214, 0.460162, 1.22929874270563, 0.767398, 0.233705, 0.457755, 1.230984583567011, 0.773695, 0.236249, 0.455289, 1.2326699945862551, 0.779968, 0.238851, 0.452765, 1.2343558354476358, 0.786212, 0.241514, 0.450184, 1.236041676309017, 0.792427, 0.244242, 0.447543, 1.2377270873282609, 0.798608, 0.24704, 0.444848, 1.2394129281896418, 0.804752, 0.249911, 0.442102, 1.2410983392088857, 0.810855, 0.252861, 0.439305, 1.2427841800702666, 0.816914, 0.255895, 0.436461, 1.2444695910895105, 0.822926, 0.259016, 0.433573, 1.2461554319508914, 0.828886, 0.262229, 0.430644, 1.2478412728122723, 0.834791, 0.26554, 0.427671, 1.2495266838315162, 0.840636, 0.268953, 0.424666, 1.2512125246928971, 0.846416, 0.272473, 0.421631, 1.252897935712141, 0.852126, 0.276106, 0.418573, 1.2545837765735222, 0.857763, 0.279857, 0.415496, 1.2562691875927658, 0.86332, 0.283729, 0.412403, 1.257955028454147, 0.868793, 0.287728, 0.409303, 1.2596408693155277, 0.874176, 0.291859, 0.406205, 1.2613262803347718, 0.879464, 0.296125, 0.403118, 1.2630121211961527, 0.884651, 0.30053, 0.400047, 1.2646975322153966, 0.889731, 0.305079, 0.397002, 1.2663833730767775, 0.8947, 0.309773, 0.393995, 1.2680687840960214, 0.899552, 0.314616, 0.391037, 1.2697546249574023, 0.904281, 0.31961, 0.388137, 1.2714404658187832, 0.908884, 0.324755, 0.385308, 1.2731258768380274, 0.913354, 0.330052, 0.382563, 1.274811717699408, 0.917689, 0.3355, 0.379915, 1.276497128718652, 0.921884, 0.341098, 0.377376, 1.278182969580033, 0.925937, 0.346844, 0.374959, 1.279868380599277, 0.929845, 0.352734, 0.372677, 1.2815542214606577, 0.933606, 0.358764, 0.370541, 1.2832400623220388, 0.937221, 0.364929, 0.368567, 1.2849254733412827, 0.940687, 0.371224, 0.366762, 1.2866113142026636, 0.944006, 0.377643, 0.365136, 1.2882967252219075, 0.94718, 0.384178, 0.363701, 1.2899825660832884, 0.95021, 0.39082, 0.362468, 1.2916679771025323, 0.953099, 0.397563, 0.361438, 1.2933538179639132, 0.955849, 0.4044, 0.360619, 1.2950396588252944, 0.958464, 0.411324, 0.360014, 1.296725069844538, 0.960949, 0.418323, 0.35963, 1.2984109107059192, 0.96331, 0.42539, 0.359469, 1.300096321725163, 0.965549, 0.432519, 0.359529, 1.301782162586544, 0.967671, 0.439703, 0.35981, 1.3034675736057877, 0.96968, 0.446936, 0.360311, 1.3051534144671688, 0.971582, 0.45421, 0.36103, 1.3068388254864127, 0.973381, 0.46152, 0.361965, 1.3085246663477936, 0.975082, 0.468861, 0.363111, 1.3102105072091748, 0.97669, 0.476226, 0.364466, 1.3118959182284184, 0.97821, 0.483612, 0.366025, 1.3135817590897994, 0.979645, 0.491014, 0.367783, 1.3152671701090433, 0.981, 0.498428, 0.369734, 1.3169530109704244, 0.982279, 0.505851, 0.371874, 1.318638421989668, 0.983485, 0.51328, 0.374198, 1.3203242628510492, 0.984622, 0.520713, 0.376698, 1.32201010371243, 0.985693, 0.528148, 0.379371, 1.323695514731674, 0.9867, 0.535582, 0.38221, 1.325381355593055, 0.987646, 0.543015, 0.38521, 1.3270667666122988, 0.988533, 0.550446, 0.388365, 1.3287526074736797, 0.989363, 0.557873, 0.391671, 1.3304380184929236, 0.990138, 0.565296, 0.395122, 1.3321238593543048, 0.990871, 0.572706, 0.398714, 1.3338097002156855, 0.991558, 0.580107, 0.402441, 1.3354951112349294, 0.992196, 0.587502, 0.406299, 1.3371809520963103, 0.992785, 0.594891, 0.410283, 1.3388663631155544, 0.993326, 0.602275, 0.41439, 1.3405522039769353, 0.993834, 0.609644, 0.418613, 1.3422376149961792, 0.994309, 0.616999, 0.42295, 1.3439234558575601, 0.994738, 0.62435, 0.427397, 1.345609296718941, 0.995122, 0.631696, 0.431951, 1.347294707738185, 0.99548, 0.639027, 0.436607, 1.3489805485995658, 0.99581, 0.646344, 0.441361, 1.3506659596188098, 0.996096, 0.653659, 0.446213, 1.3523518004801907, 0.996341, 0.660969, 0.45116, 1.3540372114994346, 0.99658, 0.668256, 0.456192, 1.3557230523608155, 0.996775, 0.675541, 0.461314, 1.3574088932221966, 0.996925, 0.682828, 0.466526, 1.3590943042414403, 0.997077, 0.690088, 0.471811, 1.3607801451028214, 0.997186, 0.697349, 0.477182, 1.3624655561220653, 0.997254, 0.704611, 0.482635, 1.3641513969834462, 0.997325, 0.711848, 0.488154, 1.36583680800269, 0.997351, 0.719089, 0.493755, 1.367522648864071, 0.997351, 0.726324, 0.499428, 1.369208489725452, 0.997341, 0.733545, 0.505167, 1.3708939007446959, 0.997285, 0.740772, 0.510983, 1.372579741606077, 0.997228, 0.747981, 0.516859, 1.3742651526253207, 0.997138, 0.75519, 0.522806, 1.3759509934867016, 0.997019, 0.762398, 0.528821, 1.3776364045059455, 0.996898, 0.769591, 0.534892, 1.3793222453673266, 0.996727, 0.776795, 0.541039, 1.3810080862287073, 0.996571, 0.783977, 0.547233, 1.3826934972479514, 0.996369, 0.791167, 0.553499, 1.3843793381093323, 0.996162, 0.798348, 0.55982, 1.3860647491285762, 0.995932, 0.805527, 0.566202, 1.3877505899899572, 0.99568, 0.812706, 0.572645, 1.389436001009201, 0.995424, 0.819875, 0.57914, 1.391121841870582, 0.995131, 0.827052, 0.585701, 1.3928072528898259, 0.994851, 0.834213, 0.592307, 1.394493093751207, 0.994524, 0.841387, 0.598983, 1.3961789346125877, 0.994222, 0.84854, 0.605696, 1.3978643456318316, 0.993866, 0.855711, 0.612482, 1.3995501864932127, 0.993545, 0.862859, 0.619299, 1.4012355975124566, 0.99317, 0.870024, 0.626189, 1.4029214383738373, 0.992831, 0.877168, 0.633109, 1.4046068493930814, 0.99244, 0.88433, 0.640099, 1.4062926902544624, 0.992089, 0.89147, 0.647116, 1.4079785311158433, 0.991688, 0.898627, 0.654202, 1.4096639421350872, 0.991332, 0.905763, 0.661309, 1.411349782996468, 0.99093, 0.912915, 0.668481, 1.413035194015712, 0.99057, 0.920049, 0.675675, 1.4147210348770929, 0.990175, 0.927196, 0.682926, 1.416406445896337, 0.989815, 0.934329, 0.690198, 1.4180922867577177, 0.989434, 0.94147, 0.697519, 1.4197781276190988, 0.989077, 0.948604, 0.704863, 1.4214635386383427, 0.988717, 0.955742, 0.712242, 1.4231493794997236, 0.988367, 0.962878, 0.719649, 1.4248347905189676, 0.988033, 0.970012, 0.727077, 1.4265206313803485, 0.987691, 0.977154, 0.734536, 1.4282060423995924, 0.987387, 0.984288, 0.742002, 1.4298918832609733, 0.987053, 0.991438, 0.749504]
separate_transform1Display_prestrainRatioLUT.ColorSpace = 'RGB'
separate_transform1Display_prestrainRatioLUT.NanColor = [0.0, 1.0, 0.0]
separate_transform1Display_prestrainRatioLUT.ScalarRangeInitialized = 1.0
# get separate opacity transfer function/opacity map for 'prestrainRatio'
separate_transform1Display_prestrainRatioPWF = GetOpacityTransferFunction('prestrainRatio', transform1Display, separate=True)
separate_transform1Display_prestrainRatioPWF.Points = [1.0000497462439073, 0.8602941036224365, 0.5, 0.0, 1.0919656743557353, 0.625, 0.5, 0.0, 1.1554957969270676, 0.6691176295280457, 0.5, 0.0, 1.2865968414177669, 0.8676470518112183, 0.5, 0.0, 1.3163486627542458, 0.6911764740943909, 0.5, 0.0, 1.4298918832609733, 0.8014705777168274, 0.5, 0.0]
separate_transform1Display_prestrainRatioPWF.ScalarRangeInitialized = 1
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'prestrainRatio'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(separate_transform1Display_prestrainRatioLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
transform1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# get opacity transfer function/opacity map for 'prestrainRatio'
prestrainRatioPWF = GetOpacityTransferFunction('prestrainRatio')
prestrainRatioPWF.Points = [1.0000497462439073, 0.8602941036224365, 0.5, 0.0, 1.0919656743557353, 0.625, 0.5, 0.0, 1.1554957969270676, 0.6691176295280457, 0.5, 0.0, 1.2865968414177669, 0.8676470518112183, 0.5, 0.0, 1.3163486627542458, 0.6911764740943909, 0.5, 0.0, 1.4298918832609733, 0.8014705777168274, 0.5, 0.0]
prestrainRatioPWF.ScalarRangeInitialized = 1
# get color legend/bar for prestrainRatioLUT in view renderView1
prestrainRatioLUTColorBar = GetScalarBar(prestrainRatioLUT, renderView1)
prestrainRatioLUTColorBar.WindowLocation = 'UpperRightCorner'
prestrainRatioLUTColorBar.Position = [0.8912839737582006, 0.6471663619744058]
prestrainRatioLUTColorBar.Title = 'prestrainRatio'
prestrainRatioLUTColorBar.ComponentTitle = ''
# find source
xMLStructuredGridReader1 = FindSource('XMLStructuredGridReader1')
# set active source
SetActiveSource(xMLStructuredGridReader1)
# get color transfer function/color map for 'elasticRatio'
elasticRatioLUT = GetColorTransferFunction('elasticRatio')
elasticRatioLUT.RGBPoints = [0.3303091106505249, 0.34902, 0.0, 0.129412, 0.34705135837933526, 0.4, 0.00392157, 0.101961, 0.3637936061081457, 0.470588, 0.0156863, 0.0901961, 0.3805358538369561, 0.54902, 0.027451, 0.0705882, 0.3972781015657665, 0.619608, 0.0627451, 0.0431373, 0.4140203492945769, 0.690196, 0.12549, 0.0627451, 0.4307625970233873, 0.741176, 0.184314, 0.0745098, 0.4475048447521977, 0.788235, 0.266667, 0.0941176, 0.46424709248100815, 0.811765, 0.345098, 0.113725, 0.48098934020981854, 0.831373, 0.411765, 0.133333, 0.4977315879386289, 0.85098, 0.47451, 0.145098, 0.5144738356674393, 0.870588, 0.54902, 0.156863, 0.5312160833962497, 0.878431, 0.619608, 0.168627, 0.5479583311250602, 0.890196, 0.658824, 0.196078, 0.5647005788538706, 0.909804, 0.717647, 0.235294, 0.581442826582681, 0.929412, 0.776471, 0.278431, 0.5951862028983068, 0.94902, 0.823529, 0.321569, 0.6108455620440179, 0.968627, 0.87451, 0.407843, 0.6278376041089421, 0.980392, 0.917647, 0.509804, 0.6451631517486243, 0.988235, 0.956863, 0.643137, 0.6541590962982686, 0.992157, 0.964706, 0.713725, 0.6644843753175806, 0.988235, 0.980392, 0.870588, 0.6651540652267329, 1.0, 1.0, 1.0, 0.6658237551358854, 0.913725, 0.988235, 0.937255, 0.6761490341551974, 0.827451, 0.980392, 0.886275, 0.6861441560492971, 0.764706, 0.980392, 0.866667, 0.6964727835181548, 0.658824, 0.980392, 0.843137, 0.708134093906226, 0.572549, 0.964706, 0.835294, 0.7237934530519369, 0.423529, 0.941176, 0.87451, 0.7361211048996146, 0.262745, 0.901961, 0.862745, 0.7521139696200834, 0.0705882, 0.854902, 0.870588, 0.7667734817314298, 0.0509804, 0.8, 0.85098, 0.7867643952095386, 0.0235294, 0.709804, 0.831373, 0.8077544860321026, 0.0313725, 0.615686, 0.811765, 0.832576542514837, 0.0313725, 0.537255, 0.788235, 0.8493187902436474, 0.0392157, 0.466667, 0.768627, 0.8660610379724578, 0.0509804, 0.396078, 0.741176, 0.8828032857012682, 0.054902, 0.317647, 0.709804, 0.8995455334300786, 0.054902, 0.243137, 0.678431, 0.916287781158889, 0.0431373, 0.164706, 0.639216, 0.9330300288876996, 0.0313725, 0.0980392, 0.6, 0.94977227661651, 0.0392157, 0.0392157, 0.560784, 0.9665145243453201, 0.105882, 0.0509804, 0.509804, 0.9832567720741308, 0.113725, 0.0235294, 0.45098, 0.9999990198029411, 0.12549, 0.0, 0.380392]
elasticRatioLUT.ColorSpace = 'Lab'
elasticRatioLUT.NanColor = [0.250004, 0.0, 0.0]
elasticRatioLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'elasticRatio'
elasticRatioPWF = GetOpacityTransferFunction('elasticRatio')
elasticRatioPWF.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
elasticRatioPWF.ScalarRangeInitialized = 1
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.Visibility = 0
# Properties modified on renderView1.AxesGrid
renderView1.AxesGrid.Visibility = 1
# get display properties
xMLStructuredGridReader1Display = GetDisplayProperties(xMLStructuredGridReader1, view=renderView1)
# hide color bar/color legend
xMLStructuredGridReader1Display.SetScalarBarVisibility(renderView1, False)
# set active source
SetActiveSource(transform1)
# Properties modified on prestrainRatioLUTColorBar
prestrainRatioLUTColorBar.WindowLocation = 'LowerRightCorner'
# Properties modified on prestrainRatioLUTColorBar
prestrainRatioLUTColorBar.HorizontalTitle = 1
elif case == 2: #elasticRatio
# get color transfer function/color map for 'elasticRatio'
elasticRatioLUT = GetColorTransferFunction('elasticRatio')
elasticRatioLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
elasticRatioLUT.InterpretValuesAsCategories = 0
elasticRatioLUT.AnnotationsInitialized = 0
elasticRatioLUT.ShowCategoricalColorsinDataRangeOnly = 0
elasticRatioLUT.RescaleOnVisibilityChange = 0
elasticRatioLUT.EnableOpacityMapping = 0
elasticRatioLUT.RGBPoints = [0.3303091106505249, 0.34902, 0.0, 0.129412, 0.34705135837933526, 0.4, 0.00392157, 0.101961, 0.3637936061081457, 0.470588, 0.0156863, 0.0901961, 0.3805358538369561, 0.54902, 0.027451, 0.0705882, 0.3972781015657665, 0.619608, 0.0627451, 0.0431373, 0.4140203492945769, 0.690196, 0.12549, 0.0627451, 0.4307625970233873, 0.741176, 0.184314, 0.0745098, 0.4475048447521977, 0.788235, 0.266667, 0.0941176, 0.46424709248100815, 0.811765, 0.345098, 0.113725, 0.48098934020981854, 0.831373, 0.411765, 0.133333, 0.4977315879386289, 0.85098, 0.47451, 0.145098, 0.5144738356674393, 0.870588, 0.54902, 0.156863, 0.5312160833962497, 0.878431, 0.619608, 0.168627, 0.5479583311250602, 0.890196, 0.658824, 0.196078, 0.5647005788538706, 0.909804, 0.717647, 0.235294, 0.581442826582681, 0.929412, 0.776471, 0.278431, 0.5951862028983068, 0.94902, 0.823529, 0.321569, 0.6108455620440179, 0.968627, 0.87451, 0.407843, 0.6278376041089421, 0.980392, 0.917647, 0.509804, 0.6451631517486243, 0.988235, 0.956863, 0.643137, 0.6541590962982686, 0.992157, 0.964706, 0.713725, 0.6644843753175806, 0.988235, 0.980392, 0.870588, 0.6651540652267329, 1.0, 1.0, 1.0, 0.6658237551358854, 0.913725, 0.988235, 0.937255, 0.6761490341551974, 0.827451, 0.980392, 0.886275, 0.6861441560492971, 0.764706, 0.980392, 0.866667, 0.6964727835181548, 0.658824, 0.980392, 0.843137, 0.708134093906226, 0.572549, 0.964706, 0.835294, 0.7237934530519369, 0.423529, 0.941176, 0.87451, 0.7361211048996146, 0.262745, 0.901961, 0.862745, 0.7521139696200834, 0.0705882, 0.854902, 0.870588, 0.7667734817314298, 0.0509804, 0.8, 0.85098, 0.7867643952095386, 0.0235294, 0.709804, 0.831373, 0.8077544860321026, 0.0313725, 0.615686, 0.811765, 0.832576542514837, 0.0313725, 0.537255, 0.788235, 0.8493187902436474, 0.0392157, 0.466667, 0.768627, 0.8660610379724578, 0.0509804, 0.396078, 0.741176, 0.8828032857012682, 0.054902, 0.317647, 0.709804, 0.8995455334300786, 0.054902, 0.243137, 0.678431, 0.916287781158889, 0.0431373, 0.164706, 0.639216, 0.9330300288876996, 0.0313725, 0.0980392, 0.6, 0.94977227661651, 0.0392157, 0.0392157, 0.560784, 0.9665145243453201, 0.105882, 0.0509804, 0.509804, 0.9832567720741308, 0.113725, 0.0235294, 0.45098, 0.9999990198029411, 0.12549, 0.0, 0.380392]
elasticRatioLUT.UseLogScale = 0
elasticRatioLUT.ColorSpace = 'Lab'
elasticRatioLUT.UseBelowRangeColor = 0
elasticRatioLUT.BelowRangeColor = [0.0, 0.0, 0.0]
elasticRatioLUT.UseAboveRangeColor = 0
elasticRatioLUT.AboveRangeColor = [0.5, 0.5, 0.5]
elasticRatioLUT.NanColor = [0.250004, 0.0, 0.0]
elasticRatioLUT.NanOpacity = 1.0
elasticRatioLUT.Discretize = 1
elasticRatioLUT.NumberOfTableValues = 256
elasticRatioLUT.ScalarRangeInitialized = 1.0
elasticRatioLUT.HSVWrap = 0
elasticRatioLUT.VectorComponent = 0
elasticRatioLUT.VectorMode = 'Magnitude'
elasticRatioLUT.AllowDuplicateScalars = 1
elasticRatioLUT.Annotations = []
elasticRatioLUT.ActiveAnnotatedValues = []
elasticRatioLUT.IndexedColors = []
elasticRatioLUT.IndexedOpacities = []
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1067, 547]
# get color legend/bar for elasticRatioLUT in view renderView1
elasticRatioLUTColorBar = GetScalarBar(elasticRatioLUT, renderView1)
elasticRatioLUTColorBar.AutoOrient = 1
elasticRatioLUTColorBar.Orientation = 'Vertical'
elasticRatioLUTColorBar.WindowLocation = 'LowerRightCorner'
elasticRatioLUTColorBar.Position = [0.89, 0.02]
elasticRatioLUTColorBar.Title = 'elasticRatio'
elasticRatioLUTColorBar.ComponentTitle = ''
elasticRatioLUTColorBar.TitleJustification = 'Centered'
elasticRatioLUTColorBar.HorizontalTitle = 0
elasticRatioLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
elasticRatioLUTColorBar.TitleOpacity = 1.0
elasticRatioLUTColorBar.TitleFontFamily = 'Arial'
elasticRatioLUTColorBar.TitleFontFile = ''
elasticRatioLUTColorBar.TitleBold = 0
elasticRatioLUTColorBar.TitleItalic = 0
elasticRatioLUTColorBar.TitleShadow = 0
elasticRatioLUTColorBar.TitleFontSize = 16
elasticRatioLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
elasticRatioLUTColorBar.LabelOpacity = 1.0
elasticRatioLUTColorBar.LabelFontFamily = 'Arial'
elasticRatioLUTColorBar.LabelFontFile = ''
elasticRatioLUTColorBar.LabelBold = 0
elasticRatioLUTColorBar.LabelItalic = 0
elasticRatioLUTColorBar.LabelShadow = 0
elasticRatioLUTColorBar.LabelFontSize = 16
elasticRatioLUTColorBar.AutomaticLabelFormat = 1
elasticRatioLUTColorBar.LabelFormat = '%-#6.3g'
elasticRatioLUTColorBar.DrawTickMarks = 1
elasticRatioLUTColorBar.DrawTickLabels = 1
elasticRatioLUTColorBar.UseCustomLabels = 0
elasticRatioLUTColorBar.CustomLabels = []
elasticRatioLUTColorBar.AddRangeLabels = 1
elasticRatioLUTColorBar.RangeLabelFormat = '%-#6.1e'
elasticRatioLUTColorBar.DrawAnnotations = 1
elasticRatioLUTColorBar.AddRangeAnnotations = 0
elasticRatioLUTColorBar.AutomaticAnnotations = 0
elasticRatioLUTColorBar.DrawNanAnnotation = 0
elasticRatioLUTColorBar.NanAnnotation = 'NaN'
elasticRatioLUTColorBar.TextPosition = 'Ticks right/top, annotations left/bottom'
elasticRatioLUTColorBar.ReverseLegend = 0
elasticRatioLUTColorBar.ScalarBarThickness = 16
elasticRatioLUTColorBar.ScalarBarLength = 0.33
# Properties modified on elasticRatioLUTColorBar
elasticRatioLUTColorBar.HorizontalTitle = 1
# invert the transfer function
elasticRatioLUT.InvertTransferFunction()
else: #angle
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'angles'))
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# update the view to ensure updated data information
renderView1.Update()
# toggle 3D widget visibility (only when running from the GUI)
Hide3DWidgets(proxy=transform1.Transform)
# reset view to fit data
renderView1.ResetCamera()
# change representation type
transform1Display.SetRepresentationType('Point Gaussian')
# Properties modified on transform1Display
transform1Display.ShaderPreset = 'Plain circle'
# set scalar coloring
ColorBy(transform1Display, ('POINTS', 'angles'))
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(typeLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
transform1Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
transform1Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'angles'
anglesLUT = GetColorTransferFunction('angles')
anglesLUT.AutomaticRescaleRangeMode = "Grow and update on 'Apply'"
anglesLUT.InterpretValuesAsCategories = 0
anglesLUT.AnnotationsInitialized = 0
anglesLUT.ShowCategoricalColorsinDataRangeOnly = 0
anglesLUT.RescaleOnVisibilityChange = 0
anglesLUT.EnableOpacityMapping = 0
anglesLUT.RGBPoints = [0.0, 0.001462, 0.000466, 0.013866, 0.006160663193689554, 0.002258, 0.001295, 0.018331, 0.012319755591052443, 0.003279, 0.002305, 0.023708, 0.018480418784742, 0.004512, 0.00349, 0.029965, 0.024639511182104886, 0.00595, 0.004843, 0.03713, 0.03080017437579444, 0.007588, 0.006356, 0.044973, 0.03695926677315698, 0.009426, 0.008022, 0.052844, 0.043119929966846535, 0.011465, 0.009828, 0.06075, 0.04928059316053644, 0.013708, 0.011771, 0.068667, 0.05543968555789898, 0.016156, 0.01384, 0.076603, 0.061600348751588534, 0.018815, 0.016026, 0.084584, 0.06775944114895142, 0.021692, 0.01832, 0.09261, 0.07392010434264097, 0.024792, 0.020715, 0.100676, 0.08007919674000387, 0.028123, 0.023201, 0.108787, 0.08623985993369342, 0.031696, 0.025765, 0.116965, 0.09240052312738298, 0.03552, 0.028397, 0.125209, 0.09855961552474586, 0.039608, 0.03109, 0.133515, 0.10472027871843542, 0.04383, 0.03383, 0.141886, 0.1108793711157983, 0.048062, 0.036607, 0.150327, 0.11704003430948787, 0.05232, 0.039407, 0.158841, 0.1231991267068504, 0.056615, 0.04216, 0.167446, 0.12935978990053995, 0.060949, 0.044794, 0.176129, 0.13552045309422986, 0.06533, 0.047318, 0.184892, 0.1416795454915924, 0.069764, 0.049726, 0.193735, 0.14784020868528194, 0.074257, 0.052017, 0.20266, 0.15399930108264484, 0.078815, 0.054184, 0.211667, 0.1601599642763344, 0.083446, 0.056225, 0.220755, 0.16631905667369729, 0.088155, 0.058133, 0.229922, 0.17247971986738683, 0.092949, 0.059904, 0.239164, 0.17863881226474973, 0.097833, 0.061531, 0.248477, 0.18479947545843928, 0.102815, 0.06301, 0.257854, 0.19096013865212885, 0.107899, 0.064335, 0.267289, 0.19711923104949172, 0.113094, 0.065492, 0.276784, 0.20327989424318127, 0.118405, 0.066479, 0.286321, 0.20943898664054383, 0.123833, 0.067295, 0.295879, 0.21559964983423338, 0.12938, 0.067935, 0.305443, 0.22175874223159628, 0.135053, 0.068391, 0.315, 0.22791940542528583, 0.140858, 0.068654, 0.324538, 0.23408006861897537, 0.146785, 0.068738, 0.334011, 0.24023916101633827, 0.152839, 0.068637, 0.343404, 0.24639982421002782, 0.159018, 0.068354, 0.352688, 0.2525589166073907, 0.165308, 0.067911, 0.361816, 0.25871957980108024, 0.171713, 0.067305, 0.370771, 0.26487867219844313, 0.178212, 0.066576, 0.379497, 0.2710393353921327, 0.184801, 0.065732, 0.387973, 0.2771999985858223, 0.19146, 0.064818, 0.396152, 0.2833590909831848, 0.198177, 0.063862, 0.404009, 0.2895197541768747, 0.204935, 0.062907, 0.411514, 0.29567884657423726, 0.211718, 0.061992, 0.418647, 0.3018395097679268, 0.218512, 0.061158, 0.425392, 0.3079986021652897, 0.225302, 0.060445, 0.431742, 0.31415926535897926, 0.232077, 0.059889, 0.437695, 0.3203199285526688, 0.238826, 0.059517, 0.443256, 0.3264790209500317, 0.245543, 0.059352, 0.448436, 0.33263968414372125, 0.25222, 0.059415, 0.453248, 0.33879877654108415, 0.258857, 0.059706, 0.45771, 0.34495943973477367, 0.265447, 0.060237, 0.46184, 0.35111853213213656, 0.271994, 0.060994, 0.46566, 0.35727919532582614, 0.278493, 0.061978, 0.46919, 0.36343985851951566, 0.284951, 0.063168, 0.472451, 0.36959895091687855, 0.291366, 0.064553, 0.475462, 0.37575961411056813, 0.29774, 0.066117, 0.478243, 0.38191870650793064, 0.304081, 0.067835, 0.480812, 0.3880793697016202, 0.310382, 0.069702, 0.483186, 0.3942384620989831, 0.316654, 0.07169, 0.48538, 0.4003991252926727, 0.322899, 0.073782, 0.487408, 0.4065597884863622, 0.329114, 0.075972, 0.489287, 0.4127188808837251, 0.335308, 0.078236, 0.491024, 0.4188795440774147, 0.341482, 0.080564, 0.492631, 0.4250386364747776, 0.347636, 0.082946, 0.494121, 0.4311992996684671, 0.353773, 0.085373, 0.495501, 0.43735839206582966, 0.359898, 0.087831, 0.496778, 0.44351905525951957, 0.366012, 0.090314, 0.49796, 0.4496797184532091, 0.372116, 0.092816, 0.499053, 0.45583881085057165, 0.378211, 0.095332, 0.500067, 0.46199947404426156, 0.384299, 0.097855, 0.501002, 0.46815856644162407, 0.390384, 0.100379, 0.501864, 0.47431922963531364, 0.396467, 0.102902, 0.502658, 0.48047832203267654, 0.402548, 0.10542, 0.503386, 0.48663898522636606, 0.408629, 0.10793, 0.504052, 0.49279807762372896, 0.414709, 0.110431, 0.504662, 0.49895874081741853, 0.420791, 0.11292, 0.505215, 0.5051194040111081, 0.426877, 0.115395, 0.505714, 0.511278496408471, 0.432967, 0.117855, 0.50616, 0.5174391596021605, 0.439062, 0.120298, 0.506555, 0.5235982519995234, 0.445163, 0.122724, 0.506901, 0.5297589151932129, 0.451271, 0.125132, 0.507198, 0.5359180075905755, 0.457386, 0.127522, 0.507448, 0.5420786707842654, 0.463508, 0.129893, 0.507652, 0.5482393339779547, 0.46964, 0.132245, 0.507809, 0.5543984263753176, 0.47578, 0.134577, 0.507921, 0.560559089569007, 0.481929, 0.136891, 0.507989, 0.5667181819663699, 0.488088, 0.139186, 0.508011, 0.5728788451600595, 0.494258, 0.141462, 0.507988, 0.5790379375574224, 0.500438, 0.143719, 0.50792, 0.585198600751112, 0.506629, 0.145958, 0.507806, 0.5913592639448015, 0.512831, 0.148179, 0.507648, 0.5975183563421644, 0.519045, 0.150383, 0.507443, 0.6036790195358539, 0.52527, 0.152569, 0.507192, 0.6098381119332165, 0.531507, 0.154739, 0.506895, 0.6159987751269064, 0.537755, 0.156894, 0.506551, 0.6221578675242689, 0.544015, 0.159033, 0.506159, 0.6283185307179585, 0.550287, 0.161158, 0.505719, 0.6344791939116484, 0.556571, 0.163269, 0.50523, 0.6406382863090109, 0.562866, 0.165368, 0.504692, 0.6467989495027004, 0.569172, 0.167454, 0.504105, 0.6529580419000633, 0.57549, 0.16953, 0.503466, 0.6591187050937529, 0.581819, 0.171596, 0.502777, 0.6652777974911158, 0.588158, 0.173652, 0.502035, 0.6714384606848054, 0.594508, 0.175701, 0.501241, 0.677599123878495, 0.600868, 0.177743, 0.500394, 0.6837582162758579, 0.607238, 0.179779, 0.499492, 0.6899188794695473, 0.613617, 0.181811, 0.498536, 0.6960779718669102, 0.620005, 0.18384, 0.497524, 0.7022386350605995, 0.626401, 0.185867, 0.496456, 0.7083977274579624, 0.632805, 0.187893, 0.495332, 0.7145583906516519, 0.639216, 0.189921, 0.49415, 0.7207190538453414, 0.645633, 0.191952, 0.49291, 0.7268781462427043, 0.652056, 0.193986, 0.491611, 0.7330388094363939, 0.658483, 0.196027, 0.490253, 0.7391979018337568, 0.664915, 0.198075, 0.488836, 0.7453585650274464, 0.671349, 0.200133, 0.487358, 0.7515176574248092, 0.677786, 0.202203, 0.485819, 0.7576783206184988, 0.684224, 0.204286, 0.484219, 0.7638389838121884, 0.690661, 0.206384, 0.482558, 0.7699980762095512, 0.697098, 0.208501, 0.480835, 0.7761587394032408, 0.703532, 0.210638, 0.479049, 0.7823178318006033, 0.709962, 0.212797, 0.477201, 0.7884784949942932, 0.716387, 0.214982, 0.47529, 0.7946375873916561, 0.722805, 0.217194, 0.473316, 0.8007982505853454, 0.729216, 0.219437, 0.471279, 0.8069573429827082, 0.735616, 0.221713, 0.46918, 0.8131180061763977, 0.742004, 0.224025, 0.467018, 0.8192786693700873, 0.748378, 0.226377, 0.464794, 0.8254377617674502, 0.754737, 0.228772, 0.462509, 0.8315984249611398, 0.761077, 0.231214, 0.460162, 0.8377575173585023, 0.767398, 0.233705, 0.457755, 0.8439181805521923, 0.773695, 0.236249, 0.455289, 0.8500772729495552, 0.779968, 0.238851, 0.452765, 0.8562379361432443, 0.786212, 0.241514, 0.450184, 0.8623985993369342, 0.792427, 0.244242, 0.447543, 0.8685576917342971, 0.798608, 0.24704, 0.444848, 0.8747183549279863, 0.804752, 0.249911, 0.442102, 0.8808774473253492, 0.810855, 0.252861, 0.439305, 0.8870381105190391, 0.816914, 0.255895, 0.436461, 0.8931972029164016, 0.822926, 0.259016, 0.433573, 0.8993578661100912, 0.828886, 0.262229, 0.430644, 0.9055185293037807, 0.834791, 0.26554, 0.427671, 0.9116776217011436, 0.840636, 0.268953, 0.424666, 0.9178382848948332, 0.846416, 0.272473, 0.421631, 0.9239973772921961, 0.852126, 0.276106, 0.418573, 0.9301580404858857, 0.857763, 0.279857, 0.415496, 0.9363171328832481, 0.86332, 0.283729, 0.412403, 0.942477796076938, 0.868793, 0.287728, 0.409303, 0.9486384592706273, 0.874176, 0.291859, 0.406205, 0.9547975516679902, 0.879464, 0.296125, 0.403118, 0.9609582148616801, 0.884651, 0.30053, 0.400047, 0.9671173072590427, 0.889731, 0.305079, 0.397002, 0.9732779704527321, 0.8947, 0.309773, 0.393995, 0.979437062850095, 0.899552, 0.314616, 0.391037, 0.9855977260437846, 0.904281, 0.31961, 0.388137, 0.9917583892374742, 0.908884, 0.324755, 0.385308, 0.9979174816348371, 0.913354, 0.330052, 0.382563, 1.0040781448285265, 0.917689, 0.3355, 0.379915, 1.0102372372258892, 0.921884, 0.341098, 0.377376, 1.0163979004195791, 0.925937, 0.346844, 0.374959, 1.022556992816942, 0.929845, 0.352734, 0.372677, 1.0287176560106313, 0.933606, 0.358764, 0.370541, 1.034878319204321, 0.937221, 0.364929, 0.368567, 1.0410374116016838, 0.940687, 0.371224, 0.366762, 1.047198074795373, 0.944006, 0.377643, 0.365136, 1.053357167192736, 0.94718, 0.384178, 0.363701, 1.0595178303864259, 0.95021, 0.39082, 0.362468, 1.0656769227837886, 0.953099, 0.397563, 0.361438, 1.071837585977478, 0.955849, 0.4044, 0.360619, 1.0779982491711675, 0.958464, 0.411324, 0.360014, 1.0841573415685304, 0.960949, 0.418323, 0.35963, 1.09031800476222, 0.96331, 0.42539, 0.359469, 1.096477097159583, 0.965549, 0.432519, 0.359529, 1.1026377603532722, 0.967671, 0.439703, 0.35981, 1.108796852750635, 0.96968, 0.446936, 0.360311, 1.114957515944325, 0.971582, 0.45421, 0.36103, 1.121116608341688, 0.973381, 0.46152, 0.361965, 1.127277271535377, 0.975082, 0.468861, 0.363111, 1.1334379347290668, 0.97669, 0.476226, 0.364466, 1.1395970271264295, 0.97821, 0.483612, 0.366025, 1.145757690320119, 0.979645, 0.491014, 0.367783, 1.1519167827174819, 0.981, 0.498428, 0.369734, 1.1580774459111713, 0.982279, 0.505851, 0.371874, 1.164236538308534, 0.983485, 0.51328, 0.374198, 1.170397201502224, 0.984622, 0.520713, 0.376698, 1.1765578646959134, 0.985693, 0.528148, 0.379371, 1.182716957093276, 0.9867, 0.535582, 0.38221, 1.188877620286966, 0.987646, 0.543015, 0.38521, 1.1950367126843289, 0.988533, 0.550446, 0.388365, 1.201197375878018, 0.989363, 0.557873, 0.391671, 1.2073564682753808, 0.990138, 0.565296, 0.395122, 1.2135171314690707, 0.990871, 0.572706, 0.398714, 1.21967779466276, 0.991558, 0.580107, 0.402441, 1.2258368870601228, 0.992196, 0.587502, 0.406299, 1.2319975502538125, 0.992785, 0.594891, 0.410283, 1.2381566426511754, 0.993326, 0.602275, 0.41439, 1.2443173058448649, 0.993834, 0.609644, 0.418613, 1.2504763982422278, 0.994309, 0.616999, 0.42295, 1.2566370614359172, 0.994738, 0.62435, 0.427397, 1.262797724629607, 0.995122, 0.631696, 0.431951, 1.2689568170269698, 0.99548, 0.639027, 0.436607, 1.275117480220659, 0.99581, 0.646344, 0.441361, 1.2812765726180217, 0.996096, 0.653659, 0.446213, 1.2874372358117117, 0.996341, 0.660969, 0.45116, 1.2935963282090743, 0.99658, 0.668256, 0.456192, 1.2997569914027638, 0.996775, 0.675541, 0.461314, 1.3059176545964537, 0.996925, 0.682828, 0.466526, 1.3120767469938164, 0.997077, 0.690088, 0.471811, 1.3182374101875058, 0.997186, 0.697349, 0.477182, 1.3243965025848687, 0.997254, 0.704611, 0.482635, 1.3305571657785582, 0.997325, 0.711848, 0.488154, 1.3367162581759209, 0.997351, 0.719089, 0.493755, 1.3428769213696108, 0.997351, 0.726324, 0.499428, 1.3490375845633003, 0.997341, 0.733545, 0.505167, 1.355196676960663, 0.997285, 0.740772, 0.510983, 1.3613573401543528, 0.997228, 0.747981, 0.516859, 1.3675164325517157, 0.997138, 0.75519, 0.522806, 1.3736770957454048, 0.997019, 0.762398, 0.528821, 1.3798361881427677, 0.996898, 0.769591, 0.534892, 1.3859968513364576, 0.996727, 0.776795, 0.541039, 1.3921575145301468, 0.996571, 0.783977, 0.547233, 1.3983166069275097, 0.996369, 0.791167, 0.553499, 1.4044772701211992, 0.996162, 0.798348, 0.55982, 1.410636362518562, 0.995932, 0.805527, 0.566202, 1.4167970257122517, 0.99568, 0.812706, 0.572645, 1.4229561181096146, 0.995424, 0.819875, 0.57914, 1.4291167813033039, 0.995131, 0.827052, 0.585701, 1.4352758737006668, 0.994851, 0.834213, 0.592307, 1.4414365368943567, 0.994524, 0.841387, 0.598983, 1.4475972000880457, 0.994222, 0.84854, 0.605696, 1.4537562924854086, 0.993866, 0.855711, 0.612482, 1.4599169556790985, 0.993545, 0.862859, 0.619299, 1.4660760480764612, 0.99317, 0.870024, 0.626189, 1.4722367112701507, 0.992831, 0.877168, 0.633109, 1.4783958036675136, 0.99244, 0.88433, 0.640099, 1.4845564668612032, 0.992089, 0.89147, 0.647116, 1.4907171300548927, 0.991688, 0.898627, 0.654202, 1.4968762224522556, 0.991332, 0.905763, 0.661309, 1.503036885645945, 0.99093, 0.912915, 0.668481, 1.5091959780433077, 0.99057, 0.920049, 0.675675, 1.5153566412369976, 0.990175, 0.927196, 0.682926, 1.5215157336343605, 0.989815, 0.934329, 0.690198, 1.5276763968280496, 0.989434, 0.94147, 0.697519, 1.5338370600217395, 0.989077, 0.948604, 0.704863, 1.5399961524191024, 0.988717, 0.955742, 0.712242, 1.5461568156127916, 0.988367, 0.962878, 0.719649, 1.5523159080101545, 0.988033, 0.970012, 0.727077, 1.5584765712038442, 0.987691, 0.977154, 0.734536, 1.564635663601207, 0.987387, 0.984288, 0.742002, 1.5707963267948966, 0.987053, 0.991438, 0.749504]
anglesLUT.UseLogScale = 0
anglesLUT.ColorSpace = 'RGB'
anglesLUT.UseBelowRangeColor = 0
anglesLUT.BelowRangeColor = [0.0, 0.0, 0.0]
anglesLUT.UseAboveRangeColor = 0
anglesLUT.AboveRangeColor = [0.5, 0.5, 0.5]
anglesLUT.NanColor = [0.0, 1.0, 0.0]
anglesLUT.NanOpacity = 1.0
anglesLUT.Discretize = 1
anglesLUT.NumberOfTableValues = 256
anglesLUT.ScalarRangeInitialized = 1.0
anglesLUT.HSVWrap = 0
anglesLUT.VectorComponent = 0
anglesLUT.VectorMode = 'Magnitude'
anglesLUT.AllowDuplicateScalars = 1
anglesLUT.Annotations = []
anglesLUT.ActiveAnnotatedValues = []
anglesLUT.IndexedColors = []
anglesLUT.IndexedOpacities = []
# get opacity transfer function/opacity map for 'angles'
anglesPWF = GetOpacityTransferFunction('angles')
anglesPWF.Points = [0.0, 0.8602941036224365, 0.5, 0.0, 0.33589355211648514, 0.625, 0.5, 0.0, 0.5680552565701278, 0.6691176295280457, 0.5, 0.0, 1.0471451860825267, 0.8676470518112183, 0.5, 0.0, 1.15586894219242, 0.6911764740943909, 0.5, 0.0, 1.5707963267948966, 0.8014705777168274, 0.5, 0.0]
anglesPWF.AllowDuplicateScalars = 1
anglesPWF.UseLogScale = 0
anglesPWF.ScalarRangeInitialized = 1
# Apply a preset using its name. Note this may not work as expected when presets have duplicate names.
anglesLUT.ApplyPreset('Cool to Warm', True)
# Properties modified on anglesLUT
anglesLUT.Annotations = ['', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0]
anglesLUT.IndexedOpacities = [1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '', '']
anglesLUT.IndexedColors = [1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0]
anglesLUT.IndexedOpacities = [1.0, 1.0, 1.0]
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0,785398163', '']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0,785398163', '$\\pi/4$']
# Properties modified on anglesLUT
anglesLUT.Annotations = ['0', '0', '1.5707963267948966', '$\\pi/2$', '0.785398163', '$\\pi/4$']
# get color legend/bar for anglesLUT in view renderView1
anglesLUTColorBar = GetScalarBar(anglesLUT, renderView1)
anglesLUTColorBar.AutoOrient = 1
anglesLUTColorBar.Orientation = 'Vertical'
anglesLUTColorBar.WindowLocation = 'LowerRightCorner'
anglesLUTColorBar.Position = [0.89, 0.02]
anglesLUTColorBar.Title = 'angles'
anglesLUTColorBar.ComponentTitle = ''
anglesLUTColorBar.TitleJustification = 'Centered'
anglesLUTColorBar.HorizontalTitle = 0
anglesLUTColorBar.TitleColor = [1.0, 1.0, 1.0]
anglesLUTColorBar.TitleOpacity = 1.0
anglesLUTColorBar.TitleFontFamily = 'Arial'
anglesLUTColorBar.TitleFontFile = ''
anglesLUTColorBar.TitleBold = 0
anglesLUTColorBar.TitleItalic = 0
anglesLUTColorBar.TitleShadow = 0
anglesLUTColorBar.TitleFontSize = 16
anglesLUTColorBar.LabelColor = [1.0, 1.0, 1.0]
anglesLUTColorBar.LabelOpacity = 1.0
anglesLUTColorBar.LabelFontFamily = 'Arial'
anglesLUTColorBar.LabelFontFile = ''
anglesLUTColorBar.LabelBold = 0
anglesLUTColorBar.LabelItalic = 0
anglesLUTColorBar.LabelShadow = 0
anglesLUTColorBar.LabelFontSize = 16
anglesLUTColorBar.AutomaticLabelFormat = 1
anglesLUTColorBar.LabelFormat = '%-#6.3g'
anglesLUTColorBar.DrawTickMarks = 1
anglesLUTColorBar.DrawTickLabels = 1
anglesLUTColorBar.UseCustomLabels = 0
anglesLUTColorBar.CustomLabels = []
anglesLUTColorBar.AddRangeLabels = 1
anglesLUTColorBar.RangeLabelFormat = '%-#6.1e'
anglesLUTColorBar.DrawAnnotations = 1
anglesLUTColorBar.AddRangeAnnotations = 0
anglesLUTColorBar.AutomaticAnnotations = 0
anglesLUTColorBar.DrawNanAnnotation = 0
anglesLUTColorBar.NanAnnotation = 'NaN'
anglesLUTColorBar.TextPosition = 'Ticks right/top, annotations left/bottom'
anglesLUTColorBar.ReverseLegend = 0
anglesLUTColorBar.ScalarBarThickness = 16
anglesLUTColorBar.ScalarBarLength = 0.33
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.DrawTickLabels = 0
anglesLUTColorBar.AddRangeLabels = 0
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.Title = 'angle $\\alpha$'
# anglesLUTColorBar.Title = 'angle $\\angle$'
anglesLUTColorBar.HorizontalTitle = 1
anglesLUTColorBar.TitleFontSize = 20
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.LabelFontSize = 20
anglesLUTColorBar.TitleFontSize = 24
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.LabelFontSize = 20
# Properties modified on anglesLUTColorBar
anglesLUTColorBar.DrawTickMarks = 0
# find source
xMLStructuredGridReader1 = FindSource('XMLStructuredGridReader1')
# set active source
SetActiveSource(xMLStructuredGridReader1)
# get color transfer function/color map for 'elasticRatio'
elasticRatioLUT = GetColorTransferFunction('elasticRatio')
elasticRatioLUT.RGBPoints = [0.3303091106505249, 0.34902, 0.0, 0.129412, 0.34705135837933526, 0.4, 0.00392157, 0.101961, 0.3637936061081457, 0.470588, 0.0156863, 0.0901961, 0.3805358538369561, 0.54902, 0.027451, 0.0705882, 0.3972781015657665, 0.619608, 0.0627451, 0.0431373, 0.4140203492945769, 0.690196, 0.12549, 0.0627451, 0.4307625970233873, 0.741176, 0.184314, 0.0745098, 0.4475048447521977, 0.788235, 0.266667, 0.0941176, 0.46424709248100815, 0.811765, 0.345098, 0.113725, 0.48098934020981854, 0.831373, 0.411765, 0.133333, 0.4977315879386289, 0.85098, 0.47451, 0.145098, 0.5144738356674393, 0.870588, 0.54902, 0.156863, 0.5312160833962497, 0.878431, 0.619608, 0.168627, 0.5479583311250602, 0.890196, 0.658824, 0.196078, 0.5647005788538706, 0.909804, 0.717647, 0.235294, 0.581442826582681, 0.929412, 0.776471, 0.278431, 0.5951862028983068, 0.94902, 0.823529, 0.321569, 0.6108455620440179, 0.968627, 0.87451, 0.407843, 0.6278376041089421, 0.980392, 0.917647, 0.509804, 0.6451631517486243, 0.988235, 0.956863, 0.643137, 0.6541590962982686, 0.992157, 0.964706, 0.713725, 0.6644843753175806, 0.988235, 0.980392, 0.870588, 0.6651540652267329, 1.0, 1.0, 1.0, 0.6658237551358854, 0.913725, 0.988235, 0.937255, 0.6761490341551974, 0.827451, 0.980392, 0.886275, 0.6861441560492971, 0.764706, 0.980392, 0.866667, 0.6964727835181548, 0.658824, 0.980392, 0.843137, 0.708134093906226, 0.572549, 0.964706, 0.835294, 0.7237934530519369, 0.423529, 0.941176, 0.87451, 0.7361211048996146, 0.262745, 0.901961, 0.862745, 0.7521139696200834, 0.0705882, 0.854902, 0.870588, 0.7667734817314298, 0.0509804, 0.8, 0.85098, 0.7867643952095386, 0.0235294, 0.709804, 0.831373, 0.8077544860321026, 0.0313725, 0.615686, 0.811765, 0.832576542514837, 0.0313725, 0.537255, 0.788235, 0.8493187902436474, 0.0392157, 0.466667, 0.768627, 0.8660610379724578, 0.0509804, 0.396078, 0.741176, 0.8828032857012682, 0.054902, 0.317647, 0.709804, 0.8995455334300786, 0.054902, 0.243137, 0.678431, 0.916287781158889, 0.0431373, 0.164706, 0.639216, 0.9330300288876996, 0.0313725, 0.0980392, 0.6, 0.94977227661651, 0.0392157, 0.0392157, 0.560784, 0.9665145243453201, 0.105882, 0.0509804, 0.509804, 0.9832567720741308, 0.113725, 0.0235294, 0.45098, 0.9999990198029411, 0.12549, 0.0, 0.380392]
elasticRatioLUT.ColorSpace = 'Lab'
elasticRatioLUT.NanColor = [0.250004, 0.0, 0.0]
elasticRatioLUT.ScalarRangeInitialized = 1.0
# get opacity transfer function/opacity map for 'elasticRatio'
elasticRatioPWF = GetOpacityTransferFunction('elasticRatio')
elasticRatioPWF.Points = [0.3303091106505249, 0.8602941036224365, 0.5, 0.0, 0.47351324129727485, 0.625, 0.5, 0.0, 0.5724925603293413, 0.6691176295280457, 0.5, 0.0, 0.7767467248559744, 0.8676470518112183, 0.5, 0.0, 0.8230997759230788, 0.6911764740943909, 0.5, 0.0, 0.9999990198029411, 0.8014705777168274, 0.5, 0.0]
elasticRatioPWF.ScalarRangeInitialized = 1
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [929, 934]
# get display properties
xMLStructuredGridReader1Display = GetDisplayProperties(xMLStructuredGridReader1, view=renderView1)
# hide color bar/color legend
xMLStructuredGridReader1Display.SetScalarBarVisibility(renderView1, False)
renderView1.OrientationAxesVisibility = 0
#### uncomment the following to render all views
# RenderAllViews()
# alternatively, if you want to write images, you can use SaveScreenshot(...).
# ----------------- EXPORT -----------------
# save screenshot
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[1257, 934])
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[2514, 1868])
# SaveScreenshot('/home/klaus/Desktop/PhaseDiagramPlot.png', renderView1, ImageResolution=[1063, 657])
#
if case == 1:
outputName = '/home/klaus/Desktop/PrestrainRatio' + ".png"
elif case == 2:
outputName = '/home/klaus/Desktop/ElasticRatio' + ".png"
else:
outputName = '/home/klaus/Desktop/CorrespondingAngle' + ".png"
# SaveScreenshot('/home/klaus/Desktop/2DPhaseDiagram.png', renderView1, ImageResolution=[2126, 1314])
SaveScreenshot(outputName , renderView1, ImageResolution=[2126, 1314])
# export view
# ExportView('/home/klaus/Desktop/PhaseDiagramPlot.pdf', view=renderView1)
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import time
from ClassifyMin import *
from HelperFunctions import *
# from scipy.io import loadmat #not Needed anymore?
import codecs
import sys
# ----------------------------------------------------------------------------------------------------------------------------
# ----- Setup Paths -----
InputFile = "/inputs/cellsolver.parset"
OutputFile = "/outputs/output.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
mu1 = 10.0
rho1 = 1.0
alpha = 2.8
beta = 2.0
theta = 1.0/4.0
gamma = 0.75
lambda1= 10.0
print('mu1: ', mu1)
print('rho1: ', rho1)
print('alpha: ', alpha)
print('beta: ', beta)
print('theta: ', theta)
print('gamma:', gamma)
print('----------------------------')
print('RunCellProblem...')
RunCellProblem(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath)
print('Read effective quantities...')
Q, B = ReadEffectiveQuantities()
print('Q:', Q)
print('B:', B)
# Compare symbolicMinimization with Classification 'ClassifyMin' :
print('Compare_Classification...')
Compare_Classification(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath)
# ------------- RUN Matlab symbolic minimization program 'symMinimization'
eng = matlab.engine.start_matlab()
# s = eng.genpath(path + '/Matlab-Programs')
s = eng.genpath(path)
eng.addpath(s, nargout=0)
# print('current Matlab folder:', eng.pwd(nargout=1))
eng.cd('Matlab-Programs', nargout=0) #switch to Matlab-Programs folder
# print('current Matlab folder:', eng.pwd(nargout=1))
Inp = False
Inp_T = True
print('Run symbolic Minimization...')
#Arguments: symMinization(print_Input,print_statPoint,print_Output,make_FunctionPlot, InputPath)
G, angle, type, kappa = eng.symMinimization(Inp,Inp,Inp,Inp, nargout=4) #Name of program:symMinimization
# G, angle, type, kappa = eng.symMinimization(Inp,Inp,Inp,Inp,path + "/outputs", nargout=4) #Optional: add Path
G = np.asarray(G) #cast Matlab Outout to numpy array
# --- print Output ---
print('Minimizer G:')
print(G)
print('angle:', angle)
print('type:', type )
print('curvature:', kappa)
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# print(sys.executable)
# from subprocess import Popen, PIPE
# --------------------------------------------------
# 'classifyMin' classifies Minimizers by utilizing the result of
# Lemma1.6
#
#
#
#
# 'classifyMin_ana': (Special-Case : Lemma1.4)
# ..additionally assumes Poisson-ratio=0 => q12==0
#
#
#
# Output : MinimizingMatrix, Angle, Type, Curvature
def determinant(q1,q2,q3,q12): # TODO General:Matrix
return q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
def harmonicMean(mu_1, beta, theta):
return mu_1*(beta/(theta+((1-theta)*beta)))
def arithmeticMean(mu_1, beta, theta):
return mu_1*((1-theta)+theta*beta)
def prestrain_b1(rho_1, beta, alpha, theta):
return (3.0*rho_1/2.0)*(1-(theta*(1+alpha)))
# return (3.0*rho_1/2.0)*beta*(1-(theta*(1+alpha)))
def prestrain_b2(rho_1, beta, alpha, theta):
return (3.0*rho_1/(2.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# return (3.0*rho_1/(4.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# Define function to be minimized
def f(a1, a2, q1, q2, q3, q12, b1, b2):
A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
a = np.array([a1, a2])
tmp = np.dot(A, a)
tmp2 = np.dot(a, tmp)
tmpB = np.dot(B, a)
return tmp2 + tmpB + q1*(b1**2) + q2*(b2**2) + q12*b1*b2
# ---- Alternative Version using alpha,beta,theta ,mu_1,rho_1
def classifyMin_ana(alpha,beta,theta,q3,mu_1,rho_1,print_Cases=False, print_Output=False):
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# 3. This additionally assumes that Poisson-Ratio = 0 => q12 == 0
q12 = 0.0
q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# print('q1: ', q1)
# print('q2: ', q2)
b1 = prestrain_b1(rho_1, beta, alpha,theta)
b2 = prestrain_b2(rho_1, beta, alpha,theta)
# print('alpha:',alpha)
# print('beta:',beta)
# print('theta:',theta)
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# Matrix Version that just gets matrices Q & B
def classifyMin_mat(Q,B,print_Cases=False, print_Output=False):
q1 = Q[0][0]
q2 = Q[1][1]
q3 = Q[2][2]
q12 = Q[0][1]
b1 = B[0]
b2 = B[1]
b3 = B[2]
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# --------------------------------------------------------------------
# Classify Type of minimizer 1 = R1 , 2 = R2 , 3 = R3 # before : destinction between which axis.. (4Types )
# where
# R1 : unique local (global) minimizer which is not axial
# R2 : continuum of local (global) minimizers which are not axial
# R3 : one or two local (global) minimizers which are axial
# Partition given by
# R1 = E1
# R2 = P1.2
# R3 = E2 U E3 U P1.1 U P2 U H
# -------------------------------------------------------------------
def classifyMin(q1, q2, q3, q12, b1, b2, print_Cases=False, print_Output=False): #ClassifyMin_hom?
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# TODO: check if Q is orthotropic here - assert()
if print_Output: print("Run ClassifyMin...")
CaseCount = 0
epsilon = sys.float_info.epsilon #Machine epsilon
B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
# print('Matrix A:', A)
# print('Matrix B:', B)
# print('Matrix rank of A:', np.linalg.matrix_rank(A))
# print('shape of A:', A.shape)
# print('shape of B:', B.shape)
# print('Matrix [A,B]:', np.c_[A, B])
# print('Matrix rank of [A,B]:', np.linalg.matrix_rank(np.c_[A, B]))
# print('shape of [A,B]:', C.shape)
#
# x = np.linalg.solve(A, B) # works only if A is not singular!!
# print("Solution LGS:", x)
# # print("sym Matrix", sym.Matrix(([A],[B])))
#
# # Test
# C = np.array([[1, 0], [0, 0]])
# d = np.array([5, 0])
# y = np.linalg.lstsq(C, d)[0]
# print("Solution LGS:", y)
# T = np.c_[C, d]
# print('T:', T)
# Trref = sym.Matrix(T).rref()[0]
# Out = np.array(Trref, dtype=float)
# print('rref:', Out)
determinant = q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
if print_Cases: print("determinant:", determinant)
# Define values for axial-Solutions (b1*,0) & (0,b2*)
b1_star = (2.0*q1*b1 + b2*q12)/(2*q1)
b2_star = (2.0*q2*b2 + b1*q12)/(2*q2)
# ------------------------------------ Parabolic Case -----------------------------------
if abs(determinant) < epsilon:
if print_Cases: print('P : parabolic case (determinant equal zero)')
print('P : parabolic case (determinant equal zero)')
# if print_Cases: print('P : parabolic case (determinant equal zero)')
# check if B is in range of A
# check if rank(A) == rank([A,B])
# OK this way? (or use Sympy?)
if np.linalg.matrix_rank(A) == np.linalg.matrix_rank(np.c_[A, B]):
if print_Cases: print('P1 (B is in the range of A)')
if (q12+q3)/2.0 <= -1.0*epsilon:
print('should not happen(not compatible with det = 0)')
if (abs(B[0]) < epsilon and abs(B[1]) < epsilon) and (q12+q3)/2.0 >= epsilon:
if print_Cases: print('P1.1')
a1 = 0.0
a2 = 0.0
type = 3
CaseCount += 1
if (abs(B[0]) >= epsilon or abs(B[1]) >= epsilon) and (q12+q3)/2.0 >= epsilon:
# Continuum of minimizers located along a line of negative slope in Lambda
if print_Cases: print('P1.2 (Continuum of minimizers located along a line of negative slope in Lambda) ')
# Just solve Aa* = b (alternatively using SymPy ?)
# we know that A is singular (det A = 0 ) here..
# & we know that there are either infinitely many solutions or a unique solution ...
# ---- determine one via Least Squares
# "If A is square and of full rank, then x (but for round-off error)
# is the “exact” solution of the equation. Else, x minimizes the
# Euclidean 2-norm || b-Ax ||. If there are multiple minimizing solutions,
# the one with the smallest 2-norm is returned. ""
# a = np.linalg.lstsq(A, B)[0] # TODO check is this Ok ?
a = np.linalg.lstsq(A, -B/2)[0] # TODO check is this Ok ? (UPDATE 13-10-21)
print("Solution LGS: a =", a)
a1 = a[0]
a2 = a[1]
type = 2
CaseCount += 1
else:
if print_Cases: print('P2 (B is not in the range of A)')
# local Minimizers occur on the boundary of Lambda...
# There are at most two local minima and they are either
# (b1_star, 0) or (0, b2_star)
# could also outsource this to another function..
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
type = 3 # 2
CaseCount += 1
# TODO Problem: angle depends on how you choose... THE angle is not defined for this case
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
type = 3 # 4
CaseCount += 1
# ------------------------------------ Elliptic Case -----------------------------------
if determinant >= epsilon:
if print_Cases: print('E : elliptic case (determinant greater zero)')
a1_star = (b1*(q12**2) + 2*b1*q3*q12 - 4*b1*q1*q2 + 4*b2*q2*q3) / \
(4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
a2_star = (b2*(q12**2) + 2*b2*q3*q12 + 4*b1*q1*q3 - 4*b2*q1*q2) / \
(4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
prod = a1_star*a2_star
if prod >= epsilon:
if print_Cases: print('(E1) - inside Lambda ')
a1 = a1_star
a2 = a2_star
type = 1 # non-axial Minimizer
CaseCount += 1
if abs(prod) < epsilon: # same as prod = 0 ? or better use <=epsilon ?
if print_Cases: print('(E2) - on the boundary of Lambda ')
a1 = a1_star
a2 = a2_star
type = 3 # could check which axis: if a1_star or a2_star close to zero.. ?
CaseCount += 1
if prod <= -1.0*epsilon:
if print_Cases: print('(E3) - Outside Lambda ')
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
type = 3 # 2
CaseCount += 1
# TODO Problem: angle depends on how you choose... THE angle is not defined for this case
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
type = 3 # 4
CaseCount += 1
# ------------------------------------ Hyperbolic Case -----------------------------------
if determinant <= -1.0*epsilon:
if print_Cases: print('H : hyperbolic case (determinant smaller zero)')
# One or two minimizers wich are axial
type = 3 # (always type 3)
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
# type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
# type = 3 # 2
CaseCount += 1
# TODO can add this case to first or second ..
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
# type = 3 # 4
CaseCount += 1
# ---------------------------------------------------------------------------------------
if (CaseCount > 1):
print('Error: More than one Case happened!')
# compute a3
# a3 = math.sqrt(2.0*a1*a2) # never needed?
# print('a1:', a1)
# print('a2:', a2)
# compute the angle <(e,e_1) where Minimizer = kappa* (e (x) e)
# e = [math.sqrt((a1/(a1+a2))), math.sqrt((a2/(a1+a2)))]
e = [((a1/(a1+a2)))**0.5, ((a2/(a1+a2)))**0.5]
angle = math.atan2(e[1], e[0])
# compute kappa
kappa = (a1 + a2)
# Minimizer G
# Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]],dtype=object)
Minimizer = np.array([[a1, (a1*a2)**0.5], [(a1*a2)**0.5, a2]],dtype=object)
# Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]])
# MinimizerVec = np.array([a1, a2],dtype=object)
MinimizerVec = np.array([a1, a2])
if print_Output:
print('--- Output ClassifyMin ---')
print("Minimizing Matrix G:")
print(Minimizer)
print("angle = ", angle)
print("type: ", type)
print("kappa = ", kappa)
return Minimizer, angle, type, kappa
# return MinimizerVec, angle, type, kappa #return Minimizer Vector instead
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ---------------------------------------------- Main ---------------------
# --- Input Parameters ----
# mu_1 = 1.0
# rho_1 = 1.0
# alpha = 9.0
# beta = 2.0
# theta = 1.0/8.0
# # define q1, q2 , mu_gamma, q12
# # 1. read from Cell-Output
# # 2. define values from analytic formulas (expect for mu_gamma)
# q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# # TEST
# q12 = 0.0 # (analytical example)
# # q12 = 12.0 # (analytical example)
# set mu_gamma to value or read from Cell-Output
# mu_gamma = q1 # TODO read from Cell-Output
# b1 = prestrain_b1(rho_1, beta, alpha, theta)
# b2 = prestrain_b2(rho_1, beta, alpha, theta)
# print('---- Input parameters: -----')
# print('mu_1: ', mu_1)
# print('rho_1: ', rho_1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# # print("machine epsilon", sys.float_info.epsilon)
#
#
# # ------- Options --------
# print_Cases = True
# print_Output = True
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
#
# G, angle, type, kappa = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
#
# Out = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('TEST:')
# Out = classifyMin_ana(alpha, beta, theta)
# print('Out[0]', Out[0])
# print('Out[1]', Out[1])
# print('Out[2]', Out[2])
# print('Out[3]', Out[3])
# #supress certain Outout..
# _,_,T,_ = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('Output only type..:', T)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# print(sys.executable)
# from subprocess import Popen, PIPE
# --------------------------------------------------
# 'classifyMin' classifies Minimizers by utilizing the result of
# Lemma1.6
#
#
#
#
# 'classifyMin_ana': (Special-Case : Lemma1.4)
# ..additionally assumes Poisson-ratio=0 => q12==0
#
#
#
# Output : MinimizingMatrix, Angle, Type, Curvature
def determinant(q1,q2,q3,q12): # TODO General:Matrix
return q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
def harmonicMean(mu_1, beta, theta):
return mu_1*(beta/(theta+(1-theta)*beta))
def arithmeticMean(mu_1, beta, theta):
return mu_1*((1-theta)+theta*beta)
def prestrain_b1(rho_1, beta, alpha, theta):
return (3.0*rho_1/2.0)*(1-(theta*(1+alpha)))
# return (3.0*rho_1/2.0)*beta*(1-(theta*(1+alpha)))
def prestrain_b2(rho_1, beta, alpha, theta):
return (3.0*rho_1/(2.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# return (3.0*rho_1/(4.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# Define function to be minimized
def f(a1, a2, q1, q2, q3, q12, b1, b2):
A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
a = np.array([a1, a2])
tmp = np.dot(A, a)
tmp2 = np.dot(a, tmp)
tmpB = np.dot(B, a)
return tmp2 + tmpB + q1*(b1**2) + q2*(b2**2) + q12*b1*b2
# ---- Alternative Version using alpha,beta,theta ,mu_1,rho_1
def classifyMin_ana(alpha,beta,theta,q3,mu_1,rho_1,print_Cases=False, print_Output=False):
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# 3. This additionally assumes that Poisson-Ratio = 0 => q12 == 0
q12 = 0.0
q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# print('q1: ', q1)
# print('q2: ', q2)
b1 = prestrain_b1(rho_1, beta, alpha,theta)
b2 = prestrain_b2(rho_1, beta, alpha,theta)
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# Matrix Version that just gets matrices Q & B
def classifyMin_mat(Q,B,print_Cases=False, print_Output=False):
q1 = Q[0][0]
q2 = Q[1][1]
q3 = Q[2][2]
q12 = Q[0][1]
b1 = B[0]
b2 = B[1]
b3 = B[2]
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# --------------------------------------------------------------------
# Classify Type of minimizer 1 = R1 , 2 = R2 , 3 = R3 # before : destinction between which axis.. (4Types )
# where
# R1 : unique local (global) minimizer which is not axial
# R2 : continuum of local (global) minimizers which are not axial
# R3 : one or two local (global) minimizers which are axial
# Partition given by
# R1 = E1
# R2 = P1.2
# R3 = E2 U E3 U P1.1 U P2 U H
# -------------------------------------------------------------------
def classifyMin(q1, q2, q3, q12, b1, b2, print_Cases=False, print_Output=False): #ClassifyMin_hom?
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# TODO: check if Q is orthotropic here - assert()
if print_Output: print("Run ClassifyMin...")
CaseCount = 0
epsilon = sys.float_info.epsilon #Machine epsilon
B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
# print('Matrix A:', A)
# print('Matrix B:', B)
# print('Matrix rank of A:', np.linalg.matrix_rank(A))
# print('shape of A:', A.shape)
# print('shape of B:', B.shape)
# print('Matrix [A,B]:', np.c_[A, B])
# print('Matrix rank of [A,B]:', np.linalg.matrix_rank(np.c_[A, B]))
# print('shape of [A,B]:', C.shape)
#
# x = np.linalg.solve(A, B) # works only if A is not singular!!
# print("Solution LGS:", x)
# # print("sym Matrix", sym.Matrix(([A],[B])))
#
# # Test
# C = np.array([[1, 0], [0, 0]])
# d = np.array([5, 0])
# y = np.linalg.lstsq(C, d)[0]
# print("Solution LGS:", y)
# T = np.c_[C, d]
# print('T:', T)
# Trref = sym.Matrix(T).rref()[0]
# Out = np.array(Trref, dtype=float)
# print('rref:', Out)
determinant = q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
if print_Cases: print("determinant:", determinant)
# Define values for axial-Solutions (b1*,0) & (0,b2*)
b1_star = (2.0*q1*b1 + b2*q12)/(2*q1)
b2_star = (2.0*q2*b2 + b1*q12)/(2*q2)
# ------------------------------------ Parabolic Case -----------------------------------
if abs(determinant) < epsilon:
if print_Cases: print('P : parabolic case (determinant equal zero)')
# if print_Cases: print('P : parabolic case (determinant equal zero)')
# check if B is in range of A
# check if rank(A) == rank([A,B])
# OK this way? (or use Sympy?)
if np.linalg.matrix_rank(A) == np.linalg.matrix_rank(np.c_[A, B]):
if print_Cases: print('P1 (B is in the range of A)')
if (q12+q3)/2.0 <= -1.0*epsilon:
print('should not happen(not compatible with det = 0)')
if (abs(B[0]) < epsilon and abs(B[1]) < epsilon) and (q12+q3)/2.0 >= epsilon:
if print_Cases: print('P1.1')
a1 = 0.0
a2 = 0.0
type = 3
CaseCount += 1
if (abs(B[0]) >= epsilon or abs(B[1]) >= epsilon) and (q12+q3)/2.0 >= epsilon:
# Continuum of minimizers located along a line of negative slope in Lambda
if print_Cases: print('P1.2 (Continuum of minimizers located along a line of negative slope in Lambda) ')
# Just solve Aa* = b (alternatively using SymPy ?)
# we know that A is singular (det A = 0 ) here..
# & we know that there are either infinitely many solutions or a unique solution ...
# ---- determine one via Least Squares
# "If A is square and of full rank, then x (but for round-off error)
# is the “exact” solution of the equation. Else, x minimizes the
# Euclidean 2-norm || b-Ax ||. If there are multiple minimizing solutions,
# the one with the smallest 2-norm is returned. ""
a = np.linalg.lstsq(A, B)[0] # TODO check is this Ok ?
print("Solution LGS: a =", a)
a1 = a[0]
a2 = a[1]
type = 2
CaseCount += 1
else:
if print_Cases: print('P2 (B is not in the range of A)')
# local Minimizers occur on the boundary of Lambda...
# There are at most two local minima and they are either
# (b1_star, 0) or (0, b2_star)
# could also outsource this to another function..
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
type = 3 # 2
CaseCount += 1
# TODO Problem: angle depends on how you choose... THE angle is not defined for this case
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
type = 3 # 4
CaseCount += 1
# ------------------------------------ Elliptic Case -----------------------------------
if determinant >= epsilon:
if print_Cases: print('E : elliptic case (determinant greater zero)')
a1_star = -(2*(b1*(q12**2) + 2*b1*q3*q12 - 4*b1*q1*q2 + 4*b2*q2*q3)) / \
(4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
a2_star = -(2*(b2*(q12**2) + 2*b2*q3*q12 + 4*b1*q1*q3 - 4*b2*q1*q2)) / \
(4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
prod = a1_star*a2_star
if prod >= epsilon:
if print_Cases: print('(E1) - inside Lambda ')
a1 = a1_star
a2 = a2_star
type = 1 # non-axial Minimizer
CaseCount += 1
if abs(prod) < epsilon: # same as prod = 0 ? or better use <=epsilon ?
if print_Cases: print('(E2) - on the boundary of Lambda ')
a1 = a1_star
a2 = a2_star
type = 3 # could check which axis: if a1_star or a2_star close to zero.. ?
CaseCount += 1
if prod <= -1.0*epsilon:
if print_Cases: print('(E3) - Outside Lambda ')
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
type = 3 # 2
CaseCount += 1
# TODO Problem: angle depends on how you choose... THE angle is not defined for this case
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
type = 3 # 4
CaseCount += 1
# ------------------------------------ Hyperbolic Case -----------------------------------
if determinant <= -1.0*epsilon:
if print_Cases: print('H : hyperbolic case (determinant smaller zero)')
# One or two minimizers wich are axial
type = 3 # (always type 3)
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = b1_star
a2 = 0.0
# type = 3 # 1
CaseCount += 1
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2_star
# type = 3 # 2
CaseCount += 1
# TODO can add this case to first or second ..
if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# Two Minimizers pick one
a1 = b1_star
a2 = 0.0
# type = 3 # 4
CaseCount += 1
# ---------------------------------------------------------------------------------------
if (CaseCount > 1):
print('Error: More than one Case happened!')
# compute a3
# a3 = math.sqrt(2.0*a1*a2) # never needed?
# compute the angle <(e,e_1) where Minimizer = kappa* (e (x) e)
e = [math.sqrt((a1/(a1+a2))), math.sqrt((a2/(a1+a2)))]
angle = math.atan2(e[1], e[0])
# compute kappa
kappa = (a1 + a2)
# Minimizer G
Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]],dtype=object)
MinimizerVec = np.array([a1, a2],dtype=object)
# Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]])
if print_Output:
print('--- Output ClassifyMin ---')
print("Minimizing Matrix G:")
print(Minimizer)
print("angle = ", angle)
print("type: ", type)
print("kappa = ", kappa)
return MinimizerVec, angle, type, kappa
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ---------------------------------------------- Main ---------------------
# --- Input Parameters ----
# mu_1 = 1.0
# rho_1 = 1.0
# alpha = 9.0
# beta = 2.0
# theta = 1.0/8.0
# # define q1, q2 , mu_gamma, q12
# # 1. read from Cell-Output
# # 2. define values from analytic formulas (expect for mu_gamma)
# q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# # TEST
# q12 = 0.0 # (analytical example)
# # q12 = 12.0 # (analytical example)
# set mu_gamma to value or read from Cell-Output
# mu_gamma = q1 # TODO read from Cell-Output
# b1 = prestrain_b1(rho_1, beta, alpha, theta)
# b2 = prestrain_b2(rho_1, beta, alpha, theta)
# print('---- Input parameters: -----')
# print('mu_1: ', mu_1)
# print('rho_1: ', rho_1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# # print("machine epsilon", sys.float_info.epsilon)
#
#
# # ------- Options --------
# print_Cases = True
# print_Output = True
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
#
# G, angle, type, kappa = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
#
# Out = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('TEST:')
# Out = classifyMin_ana(alpha, beta, theta)
# print('Out[0]', Out[0])
# print('Out[1]', Out[1])
# print('Out[2]', Out[2])
# print('Out[3]', Out[3])
# #supress certain Outout..
# _,_,T,_ = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('Output only type..:', T)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# print(sys.executable)
# from subprocess import Popen, PIPE
# --------------------------------------------------
# 'classifyMin' classifies Minimizers by utilizing the result of
# Lemma1.6
#
#
#
#
# 'classifyMin_ana': (Special-Case : Lemma1.4)
# ..additionally assumes Poisson-ratio=0 => q12==0
#
#
#
# Output : MinimizingMatrix, Angle, Type, Curvature
def get_gstar(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,q12/2], [q12/2,q2] ])
# print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
# print('g_star=', g_star)
return g_star
def determine_b(q1,q2,q12,q3,g_star):
##
# Input: g_star
# Output : b such that g_star is minimizer, i.e A*b = (1/2)*H*g_star
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
rhs = (1/2)*H.dot(g_star)
print('rhs:', rhs)
b = np.linalg.lstsq(A, rhs)[0]
print('b',b)
b1=b[0]
b2=b[1]
return b
## ---------------
def get_minimizer(q1,q2,q3,b1,b2):
# In the case if q12 == 0:
quotient = (q1*q2-q3**2)
g_star = np.array([(q1*q2*b1-q3*q2*b2)/quotient, (q1*q2*b2-q3*q1*b1)/quotient])
print('g_star=', g_star)
return g_star
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
def determinant(q1,q2,q3,q12): # TODO General:Matrix
return q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
def harmonicMean(mu_1, beta, theta):
return mu_1*(beta/(theta+((1-theta)*beta)))
def arithmeticMean(mu_1, beta, theta):
return mu_1*((1-theta)+theta*beta)
def prestrain_b1(rho_1, beta, alpha, theta):
return (3.0*rho_1/2.0)*(1-(theta*(1+alpha)))
# return (3.0*rho_1/2.0)*beta*(1-(theta*(1+alpha)))
def prestrain_b2(rho_1, beta, alpha, theta):
return (3.0*rho_1/(2.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# return (3.0*rho_1/(4.0*((1.0-theta) + theta*beta)))*(1-theta*(1+beta*alpha))
# Define function to be minimized
def f(a1, a2, q1, q2, q3, q12, b1, b2):
A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
a = np.array([a1, a2])
tmp = np.dot(A, a)
tmp2 = np.dot(a, tmp)
tmpB = np.dot(B, a)
return tmp2 + tmpB + q1*(b1**2) + q2*(b2**2) + q12*b1*b2
# ---- Alternative Version using alpha,beta,theta ,mu_1,rho_1
def classifyMin_ana(alpha,beta,theta,q3,mu_1,rho_1,print_Cases=False, print_Output=False):
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# 3. This additionally assumes that Poisson-Ratio = 0 => q12 == 0
q12 = 0.0
q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# print('q1: ', q1)
# print('q2: ', q2)
b1 = prestrain_b1(rho_1, beta, alpha,theta)
b2 = prestrain_b2(rho_1, beta, alpha,theta)
# print('alpha:',alpha)
# print('beta:',beta)
# print('theta:',theta)
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# Matrix Version that just gets matrices Q & B
def classifyMin_mat(Q,B,print_Cases=False, print_Output=False):
q1 = Q[0][0]
q2 = Q[1][1]
q3 = Q[2][2]
q12 = Q[0][1]
b1 = B[0]
b2 = B[1]
b3 = B[2]
return classifyMin(q1, q2, q3, q12, b1, b2, print_Cases, print_Output)
# --------------------------------------------------------------------
# Classify Type of minimizer 1 = R1 , 2 = R2 , 3 = R3 # before : destinction between which axis.. (4Types )
# where
# R1 : unique local (global) minimizer which is not axial
# R2 : continuum of local (global) minimizers which are not axial
# R3 : one or two local (global) minimizers which are axial
# Partition given by
# R1 = E1
# R2 = P1.2
# R3 = E2 U E3 U P1.1 U P2 U H
# -------------------------------------------------------------------
def classifyMin(q1, q2, q3, q12, b1, b2, print_Cases=False, print_Output=False): #ClassifyMin_hom?
# Assumption of Classification-Lemma1.6:
# 1. [b3 == 0]
# 2. Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
# TODO: check if Q is orthotropic here - assert()
if print_Output: print("Run ClassifyMin_NEW...")
CaseCount = 0
epsilon = sys.float_info.epsilon #Machine epsilon
# print('epsilon:',epsilon)
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,q12/2], [q12/2,q2] ])
# B = np.array([-2.0*q1*b1-q12*b2, -2.0*q2*b2-q12*b1])
# A = np.array([[q1, q3 + q12/2.0], [q3 + q12/2.0, q2]])
determinant = np.linalg.det(H)
# print('determinant:',determinant)
# determinant = q1*q2 - (q3**2 + 2*q3*q12 + q12**2)
if print_Cases: print("determinant:", determinant)
# Define values for axial-Solutions (b1*,0) & (0,b2*)
# b1_star = (2.0*q1*b1 + b2*q12)/(2*q1)
# b2_star = (2.0*q2*b2 + b1*q12)/(2*q2)
# ------------------------------------ Parabolic Case -----------------------------------
# if abs(determinant) < epsilon:
if abs(determinant) < epsilon:
if print_Cases: print('P : parabolic case (determinant equal zero)')
print('P : PARABOLIC CASE (determinant equal zero)')
# ------------------------------------ Elliptic Case -----------------------------------
if determinant >= epsilon:
if print_Cases: print('E : elliptic case (determinant greater zero)')
g_star = get_gstar(q1,q2,q12,q3,b1,b2)
# a1_star = (b1*(q12**2) + 2*b1*q3*q12 - 4*b1*q1*q2 + 4*b2*q2*q3) / \
# (4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
# a2_star = (b2*(q12**2) + 2*b2*q3*q12 + 4*b1*q1*q3 - 4*b2*q1*q2) / \
# (4*(q3**2) + 4*q3*q12 + (q12**2) - 4*q1*q2)
# prod = a1_star*a2_star
prod = g_star[0]*g_star[1]
if prod >= epsilon:
if print_Cases: print('(E1) - inside Lambda ')
# a1 = a1_star
# a2 = a2_star
# type = 1 # non-axial Minimizer
# CaseCount += 1
a1 = g_star[0]
a2 = g_star[1]
CaseCount += 1
if prod < epsilon: # same as prod = 0 ? or better use <=epsilon ?
if abs(((b2**2)/q1 - (b1**2)/q2)) < epsilon :
print('((b2**2)/q1 - (b1**2)/q2)', ((b2**2)/q1 - (b1**2)/q2))
print('two minimizers')
a1 = b1
a2 = 0.0
# type = 3 # 1
CaseCount += 1
else:
#compare energy values
if energy(b1, 0, q1, q2, q3, q12, b1, b2) > energy(0, b2, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2
CaseCount += 1
else :
a1 = b1
a2 = 0
CaseCount += 1
else :
# g_star = get_gstar(q1,q2,q12,q3,b1,b2)
# prod = g_star[0]*g_star[1]
if abs((b2**2)/q1 - (b1**2)/q2) < epsilon :
print('two minimizers')
a1 = b1
a2 = 0.0
# type = 3 # 1
CaseCount += 1
else:
#compare energy values
if energy(b1, 0, q1, q2, q3, q12, b1, b2) > energy(0, b2, q1, q2, q3, q12, b1, b2):
a1 = 0
a2 = b2
CaseCount += 1
else :
a1 = b1
a2 = 0
CaseCount += 1
#
# if print_Cases: print('(E2) - on the boundary of Lambda ')
# a1 = a1_star
# a2 = a2_star
# type = 3 # could check which axis: if a1_star or a2_star close to zero.. ?
# CaseCount += 1
#
# if prod <= -1.0*epsilon:
# if print_Cases: print('(E3) - Outside Lambda ')
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
# a1 = b1_star
# a2 = 0.0
# type = 3 # 1
# CaseCount += 1
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
# a1 = 0
# a2 = b2_star
# type = 3 # 2
# CaseCount += 1
#
# # TODO Problem: angle depends on how you choose... THE angle is not defined for this case
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# # Two Minimizers pick one
# a1 = b1_star
# a2 = 0.0
# type = 3 # 4
# CaseCount += 1
# ------------------------------------ Hyperbolic Case -----------------------------------
# if determinant <= -1.0*epsilon:
# if print_Cases: print('H : hyperbolic case (determinant smaller zero)')
# # One or two minimizers wich are axial
# type = 3 # (always type 3)
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) < f(0, b2_star, q1, q2, q3, q12, b1, b2):
# a1 = b1_star
# a2 = 0.0
# # type = 3 # 1
# CaseCount += 1
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) > f(0, b2_star, q1, q2, q3, q12, b1, b2):
# a1 = 0
# a2 = b2_star
# # type = 3 # 2
# CaseCount += 1
# # TODO can add this case to first or second ..
# if f(b1_star, 0, q1, q2, q3, q12, b1, b2) == f(0, b2_star, q1, q2, q3, q12, b1, b2):
# # Two Minimizers pick one
# a1 = b1_star
# a2 = 0.0
# # type = 3 # 4
# CaseCount += 1
# ---------------------------------------------------------------------------------------
if (CaseCount > 1):
print('Error: More than one Case happened!')
# compute a3
# a3 = math.sqrt(2.0*a1*a2) # never needed?
# print('a1:', a1)
# print('a2:', a2)
# compute the angle <(e,e_1) where Minimizer = kappa* (e (x) e)
# e = [math.sqrt((a1/(a1+a2))), math.sqrt((a2/(a1+a2)))]
e = [((a1/(a1+a2)))**0.5, ((a2/(a1+a2)))**0.5]
angle = math.atan2(e[1], e[0])
type = 1 # ToDO..
# compute kappa
kappa = (a1 + a2)
# Minimizer G
# Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]],dtype=object)
Minimizer = np.array([[a1, (a1*a2)**0.5], [(a1*a2)**0.5, a2]],dtype=object)
# Minimizer = np.array([[a1, math.sqrt(a1*a2)], [math.sqrt(a1*a2), a2]])
# MinimizerVec = np.array([a1, a2],dtype=object)
MinimizerVec = np.array([a1, a2])
if print_Output:
print('--- Output ClassifyMin ---')
print("Minimizing Matrix G:")
print(Minimizer)
print("angle = ", angle)
print("type: ", type)
print("kappa = ", kappa)
return Minimizer, angle, type, kappa
# return MinimizerVec, angle, type, kappa #return Minimizer Vector instead
# ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ---------------------------------------------- Main ---------------------
# --- Input Parameters ----
# mu_1 = 1.0
# rho_1 = 1.0
# alpha = 9.0
# beta = 2.0
# theta = 1.0/8.0
# # define q1, q2 , mu_gamma, q12
# # 1. read from Cell-Output
# # 2. define values from analytic formulas (expect for mu_gamma)
# q1 = (1.0/6.0)*harmonicMean(mu_1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu_1, beta, theta)
# # TEST
# q12 = 0.0 # (analytical example)
# # q12 = 12.0 # (analytical example)
# set mu_gamma to value or read from Cell-Output
# mu_gamma = q1 # TODO read from Cell-Output
# b1 = prestrain_b1(rho_1, beta, alpha, theta)
# b2 = prestrain_b2(rho_1, beta, alpha, theta)
# print('---- Input parameters: -----')
# print('mu_1: ', mu_1)
# print('rho_1: ', rho_1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# # print("machine epsilon", sys.float_info.epsilon)
#
#
# # ------- Options --------
# print_Cases = True
# print_Output = True
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
#
# G, angle, type, kappa = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
#
# Out = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('TEST:')
# Out = classifyMin_ana(alpha, beta, theta)
# print('Out[0]', Out[0])
# print('Out[1]', Out[1])
# print('Out[2]', Out[2])
# print('Out[3]', Out[3])
# #supress certain Outout..
# _,_,T,_ = classifyMin_ana(alpha, beta, theta, mu_gamma, q12, print_Cases, print_Output)
# print('Output only type..:', T)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import matplotlib.ticker as tickers
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
from mpl_toolkits.mplot3d import Axes3D
import pandas as pd
import matplotlib.colors as mcolors
from matplotlib import cm
from mpl_toolkits.mplot3d.proj3d import proj_transform
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
# Extra packages :
# from HelperFunctions import *
# from ClassifyMin import *
# from subprocess import Popen, PIPE
#import sys
###################### Documentation #########################
#..... add description here
###########################################################
def rot(v,alpha):
#rotate about axis v with degree deg in radians:
tmp = np.array([ [v[0]**2*(1-np.cos(alpha))+np.cos(alpha), v[0]*v[1]*(1-np.cos(alpha))-v[2]*np.sin(alpha), v[0]*v[2]*(1-np.cos(alpha))+ v[1]*np.sin(alpha) ],
[v[0]*v[1]*(1-np.cos(alpha))+v[2]*np.sin(alpha), v[1]**2*(1-np.cos(alpha))+np.cos(alpha), v[1]*v[2]*(1-np.cos(alpha))+v[0]*np.sin(alpha) ],
[v[2]*v[0]*(1-np.cos(alpha))-v[1]*np.sin(alpha), v[2]*v[1]*(1-np.cos(alpha))+v[0]*np.sin(alpha) , v[2]**2*(1-np.cos(alpha))+np.cos(alpha) ] ])
return tmp
def rotate_data(X, R):
#rotate about axis v with degree deg in radians:
# X : DataSet
# R : RotationMatrix
print('ROTATE DATA FUNCTION ---------------')
rot_matrix = R
# print('rot_matrix:', rot_matrix)
# print('rot_matrix.shape:', rot_matrix.shape)
# print('X', X)
# print('shape of X[0]', X.shape[0])
B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
# print('shape of B', B.shape)
# print('B',B)
# print('B[0,:]', B[0,:])
# print('B[0,:].shape', B[0,:].shape)
Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
print('shape of Out', Out.shape)
return Out
# def rotate_data(X, v,alpha): #(Old Version)
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
# rot_matrix = rot(v,alpha)
# # print('rot_matrix:', rot_matrix)
# # print('rot_matrix.shape:', rot_matrix.shape)
#
# # print('X', X)
# # print('shape of X[0]', X.shape[0])
# B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
#
# # print('shape of B', B.shape)
# # print('B',B)
# # print('B[0,:]', B[0,:])
# # print('B[0,:].shape', B[0,:].shape)
# Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
# print('shape of Out', Out.shape)
#
# return Out
# def translate_data(X, v): ...
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
#
# print('X', X)
# print('shape of X[0]', X.shape[0])
#
# Out = X + v
# return Out
def u(x,kappa,e):
tmp = (x.dot(e))*kappa
# print('tmp for u',tmp)
if kappa == 0 :
tmp = np.array([0*x[0], x[0]*e[0] + x[1]*e[1], x[1]*e[0] - x[0]*e[1] ])
else :
tmp = np.array([-(1/kappa)*np.cos(tmp)+(1/kappa), (1/kappa)*np.sin(tmp), -x[0]*e[1]+x[1]*e[0] ])
return tmp
def grad_u(x,kappa,e):
tmp = (x.dot(e))*kappa
# print('tmp',tmp)
grad_u = np.array([ [np.sin(tmp)*e[0], np.sin(tmp)*e[1]], [np.cos(tmp)*e[0], np.cos(tmp)*e[1]], [-e[1], e[0]] ])
# print('produkt', grad_u.dot(e) )
mapped_e = grad_u.dot(e)
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
# mapped_e = mapped_e.transpose()
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
return mapped_e
def compute_normal(x,kappa,e):
tmp = (x.dot(e))*kappa
partial1_u = np.array([ np.sin(tmp)*e[0] ,np.cos(tmp)*e[0], -e[1] ])
partial2_u = np.array([ np.sin(tmp)*e[1], np.cos(tmp)*e[1], e[0] ])
normal = np.cross(partial1_u,partial2_u)
# print('normal=',normal)
return normal
class Annotation3D(Annotation):
def __init__(self, text, xyz, *args, **kwargs):
super().__init__(text, xy=(0, 0), *args, **kwargs)
self._xyz = xyz
def draw(self, renderer):
x2, y2, z2 = proj_transform(*self._xyz, self.axes.M)
self.xy = (x2, y2)
super().draw(renderer)
def _annotate3D(ax, text, xyz, *args, **kwargs):
'''Add anotation `text` to an `Axes3d` instance.'''
annotation = Annotation3D(text, xyz, *args, **kwargs)
ax.add_artist(annotation)
setattr(Axes3D, 'annotate3D', _annotate3D)
class Arrow3D(FancyArrowPatch):
def __init__(self, x, y, z, dx, dy, dz, *args, **kwargs):
super().__init__((0, 0), (0, 0), *args, **kwargs)
self._xyz = (x, y, z)
self._dxdydz = (dx, dy, dz)
def draw(self, renderer):
x1, y1, z1 = self._xyz
dx, dy, dz = self._dxdydz
x2, y2, z2 = (x1 + dx, y1 + dy, z1 + dz)
xs, ys, zs = proj_transform((x1, x2), (y1, y2), (z1, z2), self.axes.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
super().draw(renderer)
def _arrow3D(ax, x, y, z, dx, dy, dz, *args, **kwargs):
'''Add an 3d arrow to an `Axes3D` instance.'''
arrow = Arrow3D(x, y, z, dx, dy, dz, *args, **kwargs)
ax.add_artist(arrow)
setattr(Axes3D, 'arrow3D', _arrow3D)
################################################################################################################
################################################################################################################
################################################################################################################
############################################################################################################################################
####################################################################### KAPPA NEGATIVE ####################################################
############################################################################################################################################
kappa = -2
num_Points = 200
num_Points = 100
e = np.array([1,0])
# e = np.array([0,1])
e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e = np.array([1/2,np.sqrt(3)/2])
# e = np.array([np.sqrt(3)/2,1/2])
# e = np.array([-1,0])
# e = np.array([0,-1])
# Creating dataset
# x = np.linspace(-1.5,1.5,num_Points)
x = np.linspace(-1,1,num_Points)
y = np.linspace(-1/2,1/2,num_Points)
print('type of x', type(x))
print('max of x:', max(x))
print('max of y:', max(y))
# print('x:', x)
x1, x2 = np.meshgrid(x,y)
zero = 0*x1
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# print('np.size(u1)',np.size(u1))
# print('u1.shape',u1.shape)
# colorfunction=(u1**2+u2**2)
# print('colofunction',colorfunction)
# print('u1.size:',np.size(u1))
# tmp = np.ones(np.size(u1))*kappa
# print('np.size(tmp)',np.size(tmp))
B = np.full_like(u1, 1)
# colorfunction=(u3) # TODO Color by angle
# colorfunction=(np.ones(np.size(u1))*kappa)
colorfunction=(B*kappa)
# print('colofunction',colorfunction)
norm=mcolors.Normalize(colorfunction.min(),colorfunction.max())
# -----------------------------------------------------
# Display the mesh
fig = plt.figure()
width = 6.28 *0.5
# width = 6.28
height = width / 1.618
ax = plt.axes(projection ='3d', adjustable='box')
###---TEST MAP e-vectprs!
# e1 = np.array([1,0])
# e2 = np.array([0,1])
# e3 = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e1 = np.array([0,1])
# e2 = np.array([-1,0])
# e3 = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# e1_mapped = u(e1,kappa,e1)
# e2_mapped = u(e2,kappa,e2)
# e3_mapped = u(e3,kappa,e3)
# print('e1 mapped:',e1_mapped)
# print('e2 mapped:',e2_mapped)
# print('e3 mapped:',e3_mapped)
### -----------------------------------
#--e1 :
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([0,1,0])
#--e2:
Rotation_angle = np.pi/2
Rotation_vector = np.array([1,0,0])
###--e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([1,0,0])
# #2te rotation :
# Rotation_angle = np.pi/4
# Rotation_vector = np.array([0,0,1])
Rotation_angle = -np.pi/2
Rotation_angle = 0
# Rotation_angle = np.pi/2
Rotation_vector = np.array([0,1,0])
Rotation_vector = np.array([1,0,0])
# rot(np.array([0,1,0]),np.pi/2)
# ZERO ROTATION
Rotation = rot(np.array([0,1,0]),0)
# TEST :
#DETERMINE ANGLE:
angle = math.atan2(e[1], e[0])
print('angle:', angle)
## GENERAL TRANSFORMATION / ROTATION:
Rotation = rot(np.array([0,0,1]),angle).dot(rot(np.array([0,1,0]),-np.pi/2))
Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
### if e1:
# Rotation = rot(np.array([0,0,1]),-np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
# Add another rotation around z-axis:
# Rotation = rot(np.array([0,0,1]),+np.pi).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/8).dot(Rotation)
#e3 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2))
# Rotation = rot(np.array([0,0,1]),np.pi/4)
# Rotation = rot(np.array([1,0,0]),np.pi/4)
#### if e1 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
#### if e2:
# Rotation = rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2))
# # #### if e3 :
# zufall dass np.pi/4 genau dem Winkel angle alpha entspricht?:
# (würde) bei e_2 keinen Unterschied machen um z achse zu rotieren?!
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([0,0,1]),np.pi/2).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([1,0,0]),np.pi/2)
# Rotation_vector = e3_mapped #TEST
# Rotation_vector = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_vector = np.array([0,0,1])
# v = np.array([1,0,0])
# X = np.array([u1,u2,u3])
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 2, cstride = 2, facecolors=cm.brg(colorfunction), alpha=.4, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.viridis(colorfunction), alpha=.4, zorder=4)
ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.Spectral_r(colorfunction), alpha=.4, zorder=4)
###---- PLOT PARAMETER-PLANE:
# ax.plot_surface(x1,x2,zero,color = 'w', rstride = 1, cstride = 1 )
print('------------------ Kappa : ', kappa)
#midpoint:
midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
print('midpoint',midpoint)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
# mapped_e = Rotation.dot(mapped_e)
# normal = Rotation.dot(normal)
# Plot Mapped_midPoint
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=4) # line width
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [mapped_e[0]], [mapped_e[1]], [mapped_e[2]], color="red")
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [normal[0]], [normal[1]], [normal[2]], color="blue")
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# mapped_e[0],mapped_e[1],mapped_e[2],
# mutation_scale=15,
# arrowstyle="-|>",
# linestyle='dashed',fc='green',
# lw = 2,
# ec ='green',
# zorder=3)
#
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 2,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 3)
###-- TEST Rotation :
# v = np.array([1,0,0])
# t = np.array([0,1,0])
#
# ax.arrow3D(0,0,0,
# t[0],t[1],t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
#
# # e_extend
#
# rotM = rot(v,np.pi/2)
#
# print('rotM:', rotM)
#
# rot_t = rotM.dot(t)
#
# print('rot_t:', rot_t)
#
# ax.arrow3D(0,0,0,
# rot_t[0],rot_t[1],rot_t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
### -------------------------------------------
############################################################################################################################################
####################################################################### KAPPA POSITIVE ####################################################
############################################################################################################################################
kappa = (-1)*kappa
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# ax.plot_surface(u1, u2, u3, color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.3) ##This one!
# T = rotate_data(X,Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=False)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=True)
ax.plot_surface(T[0], T[1], T[2], rstride = 2, cstride = 2, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=0.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=1, zorde5r=5)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
# print('midpoint',midpoint)
print('------------------ Kappa : ', kappa)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
# ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', markersize=10,marker='o', zorder=5)
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=5) # line width
# ax.scatter3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', s=100, zorder=5)
# mapped_e = grad_u(midpoint,kappa,e)
# normal = compute_normal(midpoint,kappa,e)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
mapped_e[0],mapped_e[1],mapped_e[2],
mutation_scale=15,
arrowstyle="-|>",
linestyle='dashed',fc='limegreen',
# linestyle='dashed',fc='green',
lw = 1.5,
ec ='limegreen',
zorder=5)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
normal[0],normal[1],normal[2],
mutation_scale=15,
lw = 1.5,
arrowstyle="-|>",
linestyle='dashed',fc='royalblue',
# linestyle='dashed',fc='yellow',
ec ='royalblue',
# ec ='orange',
zorder = 5)
############################################################################################################################################
####################################################################### KAPPA ZERO #########################################################
############################################################################################################################################
kappa = 0
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# ax.plot_surface(u1, u2, u3, rstride = 1, cstride = 1, color = 'white', alpha=0.85)
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2, antialiased=True)
# ax.plot_surface(T[0], T[1], T[2], rstride =1 , cstride = 1, color = 'white', alpha=0.55, zorder=3)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.5, zorder=2, antialiased=True)
ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 20, cstride = 20, color = 'gray', alpha=0.35, zorder=1, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'white', alpha=0.55, zorder=2)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
mapped_e = grad_u(midpoint,kappa,e)
normal_zeroCurv = compute_normal(midpoint,kappa,e)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
##----- PLOT MAPPED MIDPOINT :::
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
# linestyle='--', # line style will be dash line
linewidth=1,
zorder=5)
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# mapped_e[0],mapped_e[1],mapped_e[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='red',
# ec ='red')
#
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# normal_zeroCurv[0],normal_zeroCurv[1],normal_zeroCurv[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
##---------- PLOT MAPPED ORIGIN :::
# origin = np.array([0,0])
# origin_mapped = u(origin,kappa,e)
# print('origin_mapped', origin_mapped)
#
# ax.plot(origin_mapped[0],origin_mapped[1],origin_mapped[2], # data
# marker='o', # each marker will be rendered as a circle
# markersize=4, # marker size
# markerfacecolor='green', # marker facecolor
# markeredgecolor='black', # marker edgecolor
# markeredgewidth=1, # marker edge width
# linewidth=1,
# zorder=5) # line width
#
# # rotate mapped origin
# # v = np.array([1,0,0])
# # alpha = Rotation_angle
#
# rotM = rot(Rotation_vector,Rotation_angle)
# # origin_mRot = rotate_data(origin_mapped,v,alpha)
# origin_mRot = rotM.dot(origin_mapped)
# print('origin_mapped Rotated', origin_mRot)
#
# # --- Compute Distance to Origin 3D
# origin_3D=np.array([0,0,0])
# distance = origin_mapped-origin_3D
# print('distance', distance)
## --------------------------------------------------------
# COMPUTE ANGLE WITH Z AXIS
z = np.array([0,0,1])
print('test', normal_zeroCurv*z)
angle_z = np.arccos(normal_zeroCurv.dot(z) /( (np.linalg.norm(z)*np.linalg.norm(normal_zeroCurv) ) ))
print('angle between normal and z-axis', angle_z)
## unfinished...
###------------------------------------- PLOT :
plt.axis('off')
# plt.axis('tight')
# ADD colorbar
# scamap = plt.cm.ScalarMappable(cmap='inferno')
# fig.colorbar(scamap)
# ax.colorbar()
# ax.axis('auto')
# ax.set_title(r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e))
# ax.set_title(r'Cylindrical minimizer' + '_$e$=' + str(e))
ax.set_xlabel(r"x-axis")
ax.set_ylabel(r"y-axis")
ax.set_zlabel(r"z-axis")
# TEST :
# ax.annotate3D('point 1', (0, 0, 0), xytext=(3, 3), textcoords='offset points')
# ax.annotate3D('point 2', (0, 1, 0),
# xytext=(-30, -30),
# textcoords='offset points',
# arrowprops=dict(ec='black', fc='white', shrink=2.5))
# ax.annotate3D('point 3', (0, 0, 1),
# xytext=(30, -30),
# textcoords='offset points',
# bbox=dict(boxstyle="round", fc="lightyellow"),
# arrowprops=dict(arrowstyle="-|>", ec='black', fc='white', lw=5))
#######################################################################################################################
u1 = T[0]
u2 = T[1]
u3 = T[2]
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /3
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /2
mid_u1 = (u1.max()+u1.min()) * 0.5
mid_u2 = (u2.max()+u2.min()) * 0.5
mid_u3 = (u3.max()+u3.min()) * 0.5
ax.set_xlim(mid_u1 - max_range, mid_u1 + max_range)
ax.set_ylim(mid_u2 - max_range, mid_u2 + max_range)
ax.set_zlim(mid_u3 - max_range, mid_u3 + max_range)
##----- CHANGE CAMERA POSITION:
# ax.view_init(elev=10., azim=0)
# ax.view_init(elev=38, azim=90)
# ax.view_init(elev=38, azim=120)
# ax.view_init(elev=38)
# if e1 ::
# ax.view_init(elev=44)
# ax.view_init(elev=38, azim=-90)
# ax.view_init(elev=38, azim=0)
# if e3 ::
ax.view_init(elev=25)
# ax.set_xlim3d(-2, 2)
# ax.set_ylim3d(-1.0,3.0)
# ax.set_zlim3d(-1.5,2.5)
# ax.set_ylim3d(-10,10)
# ax.set_xlim(mid_u1 - max_range-0.2, mid_u1 + max_range+0.2)
# ax.set_zlim(mid_u3 - max_range-0.2, mid_u3 + max_range+0.2)
# ax.set_ylim(mid_u2 - max_range-0.2, mid_u2 + max_range+0.2)
# width = 6.28 *0.5
# height = width / 1.618
# # height = width / 2.5
# fig.set_size_inches(width, height)
# fig.savefig('Test-Cylindrical.pdf')
# Figurename = r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e)
Figurename = r'Cylindrical minimizer' + '_$e$=' + str(e)
# plt.savefig("test.png", bbox_inches='tight')
# plt.figure().set_size_inches(width, height)
# plt.set_size_inches(width, height)
# fig.set_size_inches(width, height)
# fig.savefig(Figurename+".pdf")
plt.savefig(Figurename+".png", bbox_inches='tight')
# plt.savefig(Figurename+".png")
plt.show()
# #---------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import matplotlib.ticker as tickers
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
from mpl_toolkits.mplot3d import Axes3D
import pandas as pd
import matplotlib.colors as mcolors
from matplotlib import cm
from mpl_toolkits.mplot3d.proj3d import proj_transform
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
import matplotlib as mpl
import seaborn as sns
import matplotlib.colors as mcolors
# Extra packages :
# from HelperFunctions import *
# from ClassifyMin import *
# from subprocess import Popen, PIPE
#import sys
###################### Documentation #########################
#..... add description here
###########################################################
def rot(v,alpha):
#rotate about axis v with degree deg in radians:
tmp = np.array([ [v[0]**2*(1-np.cos(alpha))+np.cos(alpha), v[0]*v[1]*(1-np.cos(alpha))-v[2]*np.sin(alpha), v[0]*v[2]*(1-np.cos(alpha))+ v[1]*np.sin(alpha) ],
[v[0]*v[1]*(1-np.cos(alpha))+v[2]*np.sin(alpha), v[1]**2*(1-np.cos(alpha))+np.cos(alpha), v[1]*v[2]*(1-np.cos(alpha))+v[0]*np.sin(alpha) ],
[v[2]*v[0]*(1-np.cos(alpha))-v[1]*np.sin(alpha), v[2]*v[1]*(1-np.cos(alpha))+v[0]*np.sin(alpha) , v[2]**2*(1-np.cos(alpha))+np.cos(alpha) ] ])
return tmp
def rotate_data(X, R):
#rotate about axis v with degree deg in radians:
# X : DataSet
# R : RotationMatrix
print('ROTATE DATA FUNCTION ---------------')
rot_matrix = R
# print('rot_matrix:', rot_matrix)
# print('rot_matrix.shape:', rot_matrix.shape)
# print('X', X)
# print('shape of X[0]', X.shape[0])
B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
# print('shape of B', B.shape)
# print('B',B)
# print('B[0,:]', B[0,:])
# print('B[0,:].shape', B[0,:].shape)
Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
print('shape of Out', Out.shape)
return Out
# def rotate_data(X, v,alpha): #(Old Version)
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
# rot_matrix = rot(v,alpha)
# # print('rot_matrix:', rot_matrix)
# # print('rot_matrix.shape:', rot_matrix.shape)
#
# # print('X', X)
# # print('shape of X[0]', X.shape[0])
# B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
#
# # print('shape of B', B.shape)
# # print('B',B)
# # print('B[0,:]', B[0,:])
# # print('B[0,:].shape', B[0,:].shape)
# Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
# print('shape of Out', Out.shape)
#
# return Out
# def translate_data(X, v): ...
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
#
# print('X', X)
# print('shape of X[0]', X.shape[0])
#
# Out = X + v
# return Out
def u(x,kappa,e):
tmp = (x.dot(e))*kappa
# print('tmp for u',tmp)
if kappa == 0 :
tmp = np.array([0*x[0], x[0]*e[0] + x[1]*e[1], x[1]*e[0] - x[0]*e[1] ])
else :
tmp = np.array([-(1/kappa)*np.cos(tmp)+(1/kappa), (1/kappa)*np.sin(tmp), -x[0]*e[1]+x[1]*e[0] ])
return tmp
def grad_u(x,kappa,e):
tmp = (x.dot(e))*kappa
# print('tmp',tmp)
grad_u = np.array([ [np.sin(tmp)*e[0], np.sin(tmp)*e[1]], [np.cos(tmp)*e[0], np.cos(tmp)*e[1]], [-e[1], e[0]] ])
# print('produkt', grad_u.dot(e) )
mapped_e = grad_u.dot(e)
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
# mapped_e = mapped_e.transpose()
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
return mapped_e
def compute_normal(x,kappa,e):
tmp = (x.dot(e))*kappa
partial1_u = np.array([ np.sin(tmp)*e[0] ,np.cos(tmp)*e[0], -e[1] ])
partial2_u = np.array([ np.sin(tmp)*e[1], np.cos(tmp)*e[1], e[0] ])
normal = np.cross(partial1_u,partial2_u)
# print('normal=',normal)
return normal
class Annotation3D(Annotation):
def __init__(self, text, xyz, *args, **kwargs):
super().__init__(text, xy=(0, 0), *args, **kwargs)
self._xyz = xyz
def draw(self, renderer):
x2, y2, z2 = proj_transform(*self._xyz, self.axes.M)
self.xy = (x2, y2)
super().draw(renderer)
def _annotate3D(ax, text, xyz, *args, **kwargs):
'''Add anotation `text` to an `Axes3d` instance.'''
annotation = Annotation3D(text, xyz, *args, **kwargs)
ax.add_artist(annotation)
setattr(Axes3D, 'annotate3D', _annotate3D)
class Arrow3D(FancyArrowPatch):
def __init__(self, x, y, z, dx, dy, dz, *args, **kwargs):
super().__init__((0, 0), (0, 0), *args, **kwargs)
self._xyz = (x, y, z)
self._dxdydz = (dx, dy, dz)
def draw(self, renderer):
x1, y1, z1 = self._xyz
dx, dy, dz = self._dxdydz
x2, y2, z2 = (x1 + dx, y1 + dy, z1 + dz)
xs, ys, zs = proj_transform((x1, x2), (y1, y2), (z1, z2), self.axes.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
super().draw(renderer)
def _arrow3D(ax, x, y, z, dx, dy, dz, *args, **kwargs):
'''Add an 3d arrow to an `Axes3D` instance.'''
arrow = Arrow3D(x, y, z, dx, dy, dz, *args, **kwargs)
ax.add_artist(arrow)
setattr(Axes3D, 'arrow3D', _arrow3D)
################################################################################################################
################################################################################################################
################################################################################################################
############################################################################################################################################
####################################################################### KAPPA NEGATIVE ####################################################
############################################################################################################################################
kappa = -2
num_Points = 200
# num_Points = 100
e = np.array([1,0])
# e = np.array([0,1])
# e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e = np.array([1/2,np.sqrt(3)/2])
# e = np.array([np.sqrt(3)/2,1/2])
# e = np.array([-1,0])
# e = np.array([0,-1])
# Creating dataset
# x = np.linspace(-1.5,1.5,num_Points)
x = np.linspace(-1,1,num_Points)
y = np.linspace(-1/2,1/2,num_Points)
print('type of x', type(x))
print('max of x:', max(x))
print('max of y:', max(y))
# print('x:', x)
x1, x2 = np.meshgrid(x,y)
zero = 0*x1
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# print('np.size(u1)',np.size(u1))
# print('u1.shape',u1.shape)
# colorfunction=(u1**2+u2**2)
# print('colofunction',colorfunction)
# print('u1.size:',np.size(u1))
# tmp = np.ones(np.size(u1))*kappa
# print('np.size(tmp)',np.size(tmp))
B = np.full_like(u1, 1)
# colorfunction=(u3) # TODO Color by angle
# colorfunction=(np.ones(np.size(u1))*kappa)
colorfunction=(B*kappa)
# print('colofunction',colorfunction)
norm=mcolors.Normalize(colorfunction.min(),colorfunction.max())
# -----------------------------------------------------
# Display the mesh
fig = plt.figure()
width = 6.28 *0.5
# width = 6.28
height = width / 1.618
ax = plt.axes(projection ='3d', adjustable='box')
###---TEST MAP e-vectprs!
# e1 = np.array([1,0])
# e2 = np.array([0,1])
# e3 = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e1 = np.array([0,1])
# e2 = np.array([-1,0])
# e3 = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# e1_mapped = u(e1,kappa,e1)
# e2_mapped = u(e2,kappa,e2)
# e3_mapped = u(e3,kappa,e3)
# print('e1 mapped:',e1_mapped)
# print('e2 mapped:',e2_mapped)
# print('e3 mapped:',e3_mapped)
### -----------------------------------
#--e1 :
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([0,1,0])
#--e2:
Rotation_angle = np.pi/2
Rotation_vector = np.array([1,0,0])
###--e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([1,0,0])
# #2te rotation :
# Rotation_angle = np.pi/4
# Rotation_vector = np.array([0,0,1])
Rotation_angle = -np.pi/2
Rotation_angle = 0
# Rotation_angle = np.pi/2
Rotation_vector = np.array([0,1,0])
Rotation_vector = np.array([1,0,0])
# rot(np.array([0,1,0]),np.pi/2)
# ZERO ROTATION
Rotation = rot(np.array([0,1,0]),0)
# TEST :
#DETERMINE ANGLE:
angle = math.atan2(e[1], e[0])
print('angle:', angle)
## GENERAL TRANSFORMATION / ROTATION:
Rotation = rot(np.array([0,0,1]),angle).dot(rot(np.array([0,1,0]),-np.pi/2))
# Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
### if e1:
Rotation = rot(np.array([0,0,1]),-np.pi/4).dot(Rotation)
Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
# Add another rotation around z-axis:
# Rotation = rot(np.array([0,0,1]),+np.pi).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/8).dot(Rotation)
#e3 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2))
# Rotation = rot(np.array([0,0,1]),np.pi/4)
# Rotation = rot(np.array([1,0,0]),np.pi/4)
#### if e1 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
#### if e2:
# Rotation = rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2))
# # #### if e3 :
# zufall dass np.pi/4 genau dem Winkel angle alpha entspricht?:
# (würde) bei e_2 keinen Unterschied machen um z achse zu rotieren?!
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([0,0,1]),np.pi/2).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([1,0,0]),np.pi/2)
# Rotation_vector = e3_mapped #TEST
# Rotation_vector = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_vector = np.array([0,0,1])
# v = np.array([1,0,0])
# X = np.array([u1,u2,u3])
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 2, cstride = 2, facecolors=cm.brg(colorfunction), alpha=.4, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.viridis(colorfunction), alpha=.4, zorder=4)
ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.Spectral_r(colorfunction), alpha=.4, zorder=4)
###---- PLOT PARAMETER-PLANE:
# ax.plot_surface(x1,x2,zero,color = 'w', rstride = 1, cstride = 1 )
print('------------------ Kappa : ', kappa)
#midpoint:
midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
print('midpoint',midpoint)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
# mapped_e = Rotation.dot(mapped_e)
# normal = Rotation.dot(normal)
# Plot Mapped_midPoint
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=4) # line width
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [mapped_e[0]], [mapped_e[1]], [mapped_e[2]], color="red")
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [normal[0]], [normal[1]], [normal[2]], color="blue")
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# mapped_e[0],mapped_e[1],mapped_e[2],
# mutation_scale=15,
# arrowstyle="-|>",
# linestyle='dashed',fc='green',
# lw = 2,
# ec ='green',
# zorder=3)
#
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 2,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 3)
###-- TEST Rotation :
# v = np.array([1,0,0])
# t = np.array([0,1,0])
#
# ax.arrow3D(0,0,0,
# t[0],t[1],t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
#
# # e_extend
#
# rotM = rot(v,np.pi/2)
#
# print('rotM:', rotM)
#
# rot_t = rotM.dot(t)
#
# print('rot_t:', rot_t)
#
# ax.arrow3D(0,0,0,
# rot_t[0],rot_t[1],rot_t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
### -------------------------------------------
############################################################################################################################################
####################################################################### KAPPA POSITIVE ####################################################
############################################################################################################################################
kappa = (-1)*kappa
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# ax.plot_surface(u1, u2, u3, color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.3) ##This one!
# T = rotate_data(X,Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
## GET COLORS :
# deep_colors = sns.color_palette("pastel")
# print('deep_colors.as_hex():',deep_colors.as_hex())
#
#
# diverging_colors = sns.color_palette("RdBu", 10)
# print('diverging_colors.as_hex():',diverging_colors.as_hex())
#
# pal = sns.color_palette("Blues")
# pal = sns.color_palette()
# print(pal.as_hex())
#
# # flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
# flatui = ["coral","white", "cornflowerblue"]
# flatui = ["cornflowerblue", "coral"]
# # flatui = ['#4c72b0','white', '#c44e52']
# # flatui = ['#4c72b0','white', '#8de5a1']
# # flatui = ['#a1c9f4', '#ffb482','#ff9f9b'] #Test colors
# # flatui = ['#4c72b0','white', '#ffb482']
# # flatui = ['#4c72b0','white', '#ff9f9b']
# # flatui = ['#4c72b0','white', '#ab162a']
#
# # flatui = ['#4c72b0','white', '#eb9172']
# # flatui = ['#4c72b0','white', '#64b5cd']
# # cmap = mpl.colors.ListedColormap(sns.color_palette(flatui).as_hex())
# # cmap = mpl.colors.ListedColormap(sns.color_palette(flatui).as_hex())
# # cmap = mpl.colors.ListedColormap(sns.color_palette("RdBu_r", 10).as_hex())
# # cmap = mpl.colors.ListedColormap(sns.color_palette("coolwarm", 10).as_hex()) #Discrete CMAP
# # cmap = sns.color_palette("coolwarm", as_cmap=True)
# # cmap = sns.color_palette("RdBu_r", as_cmap=True)
#
# # cmap=plt.cm.gnuplot
# # cmap = sns.color_palette("vlag", as_cmap=True)
# # cmap = sns.color_palette("icefire", as_cmap=True) ## THIS !
# # cmap = sns.color_palette("Spectral_r", as_cmap=True)
# # cmap = sns.color_palette("cubehelix", as_cmap=True)
#
# # cmap = sns.color_palette("flare_r", as_cmap=True)
# cmap = sns.color_palette("gnuplot", as_cmap=True)
# cmap = sns.color_palette("plasma", as_cmap=True)
# cmap = sns.diverging_palette(220, 20, as_cmap=True)
# cmap = sns.diverging_palette(250, 30, l=65, center="dark", as_cmap=True)
# cmap = mpl.colors.ListedColormap(sns.color_palette().as_hex())
# # cmap = mpl.colors.LinearSegmentedColormap.from_list("", sns.color_palette(flatui).as_hex())
# cmap = mpl.colors.ListedColormap("", sns.color_palette(flatui).as_hex())
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["orange"])
# cmaps = cmap(colorfunction)
# cmap = plt.cm.Spectral(colorfunction)
# # cmap = plt.cm.coolwarm(colorfunction)
# cmap = plt.cm.coolwarm_r(colorfunction)
cmap = plt.cm.bwr_r(colorfunction)
# cmap = plt.cm.PiYG(colorfunction)
# cmap = plt.cm.seismic_r(colorfunction)
# cmap = plt.cm.hsv(colorfunction)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=False)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=True)
# ax.plot_surface(T[0], T[1], T[2], rstride = 2, cstride = 2, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 2, cstride = 2, facecolors=cmap, alpha=.4, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=0.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=1, zorde5r=5)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
# print('midpoint',midpoint)
print('------------------ Kappa : ', kappa)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
# ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', markersize=10,marker='o', zorder=5)
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=5) # line width
# ax.scatter3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', s=100, zorder=5)
# mapped_e = grad_u(midpoint,kappa,e)
# normal = compute_normal(midpoint,kappa,e)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
mapped_e[0],mapped_e[1],mapped_e[2],
mutation_scale=15,
arrowstyle="-|>",
linestyle='dashed',fc='limegreen',
# linestyle='dashed',fc='green',
lw = 1.5,
ec ='limegreen',
zorder=5)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
normal[0],normal[1],normal[2],
mutation_scale=15,
lw = 1.5,
arrowstyle="-|>",
linestyle='dashed',fc='royalblue',
# linestyle='dashed',fc='yellow',
ec ='royalblue',
# ec ='orange',
zorder = 5)
############################################################################################################################################
####################################################################### KAPPA ZERO #########################################################
############################################################################################################################################
kappa = 0
if kappa == 0 :
u1 = 0*x1
u2 = x1*e[0] + x2*e[1]
u3 = x2*e[0] - x1*e[1]
else :
u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
u3 = x2*e[0] -x1*e[1]
# ax.plot_surface(u1, u2, u3, rstride = 1, cstride = 1, color = 'white', alpha=0.85)
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2, antialiased=True)
# ax.plot_surface(T[0], T[1], T[2], rstride =1 , cstride = 1, color = 'white', alpha=0.55, zorder=3)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.5, zorder=2, antialiased=True)
ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 20, cstride = 20, color = 'gray', alpha=0.35, zorder=1, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'white', alpha=0.55, zorder=2)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
mapped_e = grad_u(midpoint,kappa,e)
normal_zeroCurv = compute_normal(midpoint,kappa,e)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
##----- PLOT MAPPED MIDPOINT :::
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
# linestyle='--', # line style will be dash line
linewidth=1,
zorder=5)
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# mapped_e[0],mapped_e[1],mapped_e[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='red',
# ec ='red')
#
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# normal_zeroCurv[0],normal_zeroCurv[1],normal_zeroCurv[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
##---------- PLOT MAPPED ORIGIN :::
# origin = np.array([0,0])
# origin_mapped = u(origin,kappa,e)
# print('origin_mapped', origin_mapped)
#
# ax.plot(origin_mapped[0],origin_mapped[1],origin_mapped[2], # data
# marker='o', # each marker will be rendered as a circle
# markersize=4, # marker size
# markerfacecolor='green', # marker facecolor
# markeredgecolor='black', # marker edgecolor
# markeredgewidth=1, # marker edge width
# linewidth=1,
# zorder=5) # line width
#
# # rotate mapped origin
# # v = np.array([1,0,0])
# # alpha = Rotation_angle
#
# rotM = rot(Rotation_vector,Rotation_angle)
# # origin_mRot = rotate_data(origin_mapped,v,alpha)
# origin_mRot = rotM.dot(origin_mapped)
# print('origin_mapped Rotated', origin_mRot)
#
# # --- Compute Distance to Origin 3D
# origin_3D=np.array([0,0,0])
# distance = origin_mapped-origin_3D
# print('distance', distance)
## --------------------------------------------------------
# COMPUTE ANGLE WITH Z AXIS
z = np.array([0,0,1])
print('test', normal_zeroCurv*z)
angle_z = np.arccos(normal_zeroCurv.dot(z) /( (np.linalg.norm(z)*np.linalg.norm(normal_zeroCurv) ) ))
print('angle between normal and z-axis', angle_z)
## unfinished...
###------------------------------------- PLOT :
plt.axis('off')
# plt.axis('tight')
# ADD colorbar
# scamap = plt.cm.ScalarMappable(cmap='inferno')
# fig.colorbar(scamap)
# ax.colorbar()
# ax.axis('auto')
# ax.set_title(r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e))
# ax.set_title(r'Cylindrical minimizer' + '_$e$=' + str(e))
ax.set_xlabel(r"x-axis")
ax.set_ylabel(r"y-axis")
ax.set_zlabel(r"z-axis")
# TEST :
# ax.annotate3D('point 1', (0, 0, 0), xytext=(3, 3), textcoords='offset points')
# ax.annotate3D('point 2', (0, 1, 0),
# xytext=(-30, -30),
# textcoords='offset points',
# arrowprops=dict(ec='black', fc='white', shrink=2.5))
# ax.annotate3D('point 3', (0, 0, 1),
# xytext=(30, -30),
# textcoords='offset points',
# bbox=dict(boxstyle="round", fc="lightyellow"),
# arrowprops=dict(arrowstyle="-|>", ec='black', fc='white', lw=5))
#######################################################################################################################
u1 = T[0]
u2 = T[1]
u3 = T[2]
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /3
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /2
mid_u1 = (u1.max()+u1.min()) * 0.5
mid_u2 = (u2.max()+u2.min()) * 0.5
mid_u3 = (u3.max()+u3.min()) * 0.5
ax.set_xlim(mid_u1 - max_range, mid_u1 + max_range)
ax.set_ylim(mid_u2 - max_range, mid_u2 + max_range)
ax.set_zlim(mid_u3 - max_range, mid_u3 + max_range)
##----- CHANGE CAMERA POSITION:
# ax.view_init(elev=10., azim=0)
# ax.view_init(elev=38, azim=90)
# ax.view_init(elev=38, azim=120)
# ax.view_init(elev=38)
# if e1 ::
# ax.view_init(elev=44)
# ax.view_init(elev=38, azim=-90)
# ax.view_init(elev=38, azim=0)
# if e3 ::
ax.view_init(elev=25)
# ax.set_xlim3d(-2, 2)
# ax.set_ylim3d(-1.0,3.0)
# ax.set_zlim3d(-1.5,2.5)
# ax.set_ylim3d(-10,10)
# ax.set_xlim(mid_u1 - max_range-0.2, mid_u1 + max_range+0.2)
# ax.set_zlim(mid_u3 - max_range-0.2, mid_u3 + max_range+0.2)
# ax.set_ylim(mid_u2 - max_range-0.2, mid_u2 + max_range+0.2)
# width = 6.28 *0.5
# height = width / 1.618
# # height = width / 2.5
# fig.set_size_inches(width, height)
# fig.savefig('Test-Cylindrical.pdf')
# Figurename = r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e)
Figurename = r'Cylindrical minimizer' + '_$e$=' + str(e)
# plt.savefig("test.png", bbox_inches='tight')
# plt.figure().set_size_inches(width, height)
# plt.set_size_inches(width, height)
# fig.set_size_inches(width, height)
# fig.savefig(Figurename+".pdf")
plt.savefig(Figurename+".png", bbox_inches='tight')
# plt.savefig(Figurename+".png")
plt.show()
# #---------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import matplotlib.ticker as tickers
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
from mpl_toolkits.mplot3d import Axes3D
import pandas as pd
import matplotlib.colors as mcolors
from matplotlib import cm
from mpl_toolkits.mplot3d.proj3d import proj_transform
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
# Extra packages :
# from HelperFunctions import *
# from ClassifyMin import *
# from subprocess import Popen, PIPE
#import sys
###################### Documentation #########################
#..... add description here
###########################################################
def rot(v,alpha):
#rotate about axis v with degree deg in radians:
tmp = np.array([ [v[0]**2*(1-np.cos(alpha))+np.cos(alpha), v[0]*v[1]*(1-np.cos(alpha))-v[2]*np.sin(alpha), v[0]*v[2]*(1-np.cos(alpha))+ v[1]*np.sin(alpha) ],
[v[0]*v[1]*(1-np.cos(alpha))+v[2]*np.sin(alpha), v[1]**2*(1-np.cos(alpha))+np.cos(alpha), v[1]*v[2]*(1-np.cos(alpha))+v[0]*np.sin(alpha) ],
[v[2]*v[0]*(1-np.cos(alpha))-v[1]*np.sin(alpha), v[2]*v[1]*(1-np.cos(alpha))+v[0]*np.sin(alpha) , v[2]**2*(1-np.cos(alpha))+np.cos(alpha) ] ])
return tmp
def rotate_data(X, R):
#rotate about axis v with degree deg in radians:
# X : DataSet
# R : RotationMatrix
print('ROTATE DATA FUNCTION ---------------')
rot_matrix = R
# print('rot_matrix:', rot_matrix)
# print('rot_matrix.shape:', rot_matrix.shape)
# print('X', X)
# print('shape of X[0]', X.shape[0])
B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
# print('shape of B', B.shape)
# print('B',B)
# print('B[0,:]', B[0,:])
# print('B[0,:].shape', B[0,:].shape)
Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
print('shape of Out', Out.shape)
return Out
# def rotate_data(X, v,alpha): #(Old Version)
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
# rot_matrix = rot(v,alpha)
# # print('rot_matrix:', rot_matrix)
# # print('rot_matrix.shape:', rot_matrix.shape)
#
# # print('X', X)
# # print('shape of X[0]', X.shape[0])
# B = np.dot(rot_matrix, X.reshape(rot_matrix.shape[1],-1))
#
# # print('shape of B', B.shape)
# # print('B',B)
# # print('B[0,:]', B[0,:])
# # print('B[0,:].shape', B[0,:].shape)
# Out = np.array([B[0,:].reshape(X.shape[1],X.shape[2]), B[1,:].reshape(X.shape[1],X.shape[2]), B[2,:].reshape(X.shape[1],X.shape[2])])
# print('shape of Out', Out.shape)
#
# return Out
# def translate_data(X, v): ...
# #rotate about axis v with degree deg in radians:
# # X : DataSet
# print('ROTATE DATA FUNCTION ---------------')
# # v = np.array([1,0,0])
# # rotM = rot(v,np.pi/2)
# # print('rotM:', rotM)
#
# print('X', X)
# print('shape of X[0]', X.shape[0])
#
# Out = X + v
# return Out
# def u(x,kappa,e):
#
# tmp = (x.dot(e))*kappa
# # print('tmp for u',tmp)
# if kappa == 0 :
# tmp = np.array([0*x[0], x[0]*e[0] + x[1]*e[1], x[1]*e[0] - x[0]*e[1] ])
# else :
# tmp = np.array([-(1/kappa)*np.cos(tmp)+(1/kappa), (1/kappa)*np.sin(tmp), -x[0]*e[1]+x[1]*e[0] ])
# return tmp
def u(x,kappa,e):
tmp = (x.dot(e))*((-1)*kappa)
# print('tmp for u',tmp)
if kappa == 0 :
tmp = np.array([x[0]*e[0] + x[1]*e[1], x[1]*e[0] - x[0]*e[1], 0*x[0] ])
else :
tmp = np.array([ -(1/kappa)*np.sin(tmp), -x[0]*e[1]+x[1]*e[0], (1/kappa)*np.cos(tmp)-(1/kappa) ])
return tmp
# def grad_u(x,kappa,e):
#
# tmp = (x.dot(e))*kappa
# # print('tmp',tmp)
#
# grad_u = np.array([ [np.sin(tmp)*e[0], np.sin(tmp)*e[1]], [np.cos(tmp)*e[0], np.cos(tmp)*e[1]], [-e[1], e[0]] ])
# # print('produkt', grad_u.dot(e) )
# mapped_e = grad_u.dot(e)
# # print('mapped_e:', mapped_e)
# # print('siize of mapped_e', mapped_e.shape)
# # mapped_e = mapped_e.transpose()
# # print('mapped_e:', mapped_e)
# # print('siize of mapped_e', mapped_e.shape)
# return mapped_e
#
def grad_u(x,kappa,e):
tmp = (x.dot(e))*(-1)*kappa
# print('tmp',tmp)
grad_u = np.array([ [np.cos(tmp)*e[0], np.cos(tmp)*e[1]], [-e[1], e[0]], [np.sin(tmp)*e[0], np.sin(tmp)*e[1]] ])
# print('produkt', grad_u.dot(e) )
mapped_e = grad_u.dot(e)
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
# mapped_e = mapped_e.transpose()
# print('mapped_e:', mapped_e)
# print('siize of mapped_e', mapped_e.shape)
return mapped_e
def compute_normal(x,kappa,e):
tmp = (x.dot(e))*(-1)*kappa
partial1_u = np.array([ np.cos(tmp)*e[0], -e[1],np.sin(tmp)*e[0] ])
partial2_u = np.array([ np.cos(tmp)*e[1], e[0], np.sin(tmp)*e[1] ])
normal = np.cross(partial1_u,partial2_u)
# print('normal=',normal)
return normal
class Annotation3D(Annotation):
def __init__(self, text, xyz, *args, **kwargs):
super().__init__(text, xy=(0, 0), *args, **kwargs)
self._xyz = xyz
def draw(self, renderer):
x2, y2, z2 = proj_transform(*self._xyz, self.axes.M)
self.xy = (x2, y2)
super().draw(renderer)
def _annotate3D(ax, text, xyz, *args, **kwargs):
'''Add anotation `text` to an `Axes3d` instance.'''
annotation = Annotation3D(text, xyz, *args, **kwargs)
ax.add_artist(annotation)
setattr(Axes3D, 'annotate3D', _annotate3D)
class Arrow3D(FancyArrowPatch):
def __init__(self, x, y, z, dx, dy, dz, *args, **kwargs):
super().__init__((0, 0), (0, 0), *args, **kwargs)
self._xyz = (x, y, z)
self._dxdydz = (dx, dy, dz)
def draw(self, renderer):
x1, y1, z1 = self._xyz
dx, dy, dz = self._dxdydz
x2, y2, z2 = (x1 + dx, y1 + dy, z1 + dz)
xs, ys, zs = proj_transform((x1, x2), (y1, y2), (z1, z2), self.axes.M)
self.set_positions((xs[0], ys[0]), (xs[1], ys[1]))
super().draw(renderer)
def _arrow3D(ax, x, y, z, dx, dy, dz, *args, **kwargs):
'''Add an 3d arrow to an `Axes3D` instance.'''
arrow = Arrow3D(x, y, z, dx, dy, dz, *args, **kwargs)
ax.add_artist(arrow)
setattr(Axes3D, 'arrow3D', _arrow3D)
################################################################################################################
################################################################################################################
################################################################################################################
############################################################################################################################################
####################################################################### KAPPA NEGATIVE ####################################################
############################################################################################################################################
kappa = -2
num_Points = 200
num_Points = 100
e = np.array([1,0])
# e = np.array([0,1])
# e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e = np.array([1/2,np.sqrt(3)/2])
# e = np.array([np.sqrt(3)/2,1/2])
# e = np.array([-1,0])
# e = np.array([0,-1])
# Creating dataset
# x = np.linspace(-1.5,1.5,num_Points)
x = np.linspace(-1,1,num_Points)
y = np.linspace(-1/2,1/2,num_Points)
print('type of x', type(x))
print('max of x:', max(x))
print('max of y:', max(y))
# print('x:', x)
x1, x2 = np.meshgrid(x,y)
zero = 0*x1
if kappa == 0 :
# u1 = 0*x1
# u2 = x1*e[0] + x2*e[1]
# u3 = x2*e[0] - x1*e[1]
u1 = x1*e[0] + x2*e[1]
u2 = x2*e[0] - x1*e[1]
u3 = 0*x1
else :
# u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
# u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
# u3 = x2*e[0] -x1*e[1]
u1 = -(1/kappa)*np.sin((-1)*kappa*(x1*e[0]+x2*e[1]))
u2 = x2*e[0] -x1*e[1]
u3 = (1/kappa)*np.cos((-1)*kappa*(x1*e[0]+x2*e[1]))-(1/kappa)
# print('np.size(u1)',np.size(u1))
# print('u1.shape',u1.shape)
# colorfunction=(u1**2+u2**2)
# print('colofunction',colorfunction)
# print('u1.size:',np.size(u1))
# tmp = np.ones(np.size(u1))*kappa
# print('np.size(tmp)',np.size(tmp))
B = np.full_like(u1, 1)
# colorfunction=(u3) # TODO Color by angle
# colorfunction=(np.ones(np.size(u1))*kappa)
colorfunction=(B*kappa)
# print('colofunction',colorfunction)
norm=mcolors.Normalize(colorfunction.min(),colorfunction.max())
# -----------------------------------------------------
# Display the mesh
fig = plt.figure()
width = 6.28 *0.5
# width = 6.28
height = width / 1.618
ax = plt.axes(projection ='3d', adjustable='box')
###---TEST MAP e-vectprs!
# e1 = np.array([1,0])
# e2 = np.array([0,1])
# e3 = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# e1 = np.array([0,1])
# e2 = np.array([-1,0])
# e3 = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# e1_mapped = u(e1,kappa,e1)
# e2_mapped = u(e2,kappa,e2)
# e3_mapped = u(e3,kappa,e3)
# print('e1 mapped:',e1_mapped)
# print('e2 mapped:',e2_mapped)
# print('e3 mapped:',e3_mapped)
### -----------------------------------
#--e1 :
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([0,1,0])
#--e2:
Rotation_angle = np.pi/2
Rotation_vector = np.array([1,0,0])
###--e = np.array([1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_angle = -np.pi/2
# Rotation_vector = np.array([1,0,0])
# #2te rotation :
# Rotation_angle = np.pi/4
# Rotation_vector = np.array([0,0,1])
# Rotation_angle = -np.pi/2
# Rotation_angle = 0
# # Rotation_angle = np.pi/2
# Rotation_vector = np.array([0,1,0])
# Rotation_vector = np.array([1,0,0])
# rot(np.array([0,1,0]),np.pi/2)
# ZERO ROTATION
Rotation = rot(np.array([0,1,0]),0)
# TEST :
#DETERMINE ANGLE:
angle = math.atan2(e[1], e[0])
print('angle:', angle)
## GENERAL TRANSFORMATION / ROTATION:
# Rotation = rot(np.array([0,0,1]),angle).dot(rot(np.array([0,1,0]),-np.pi/2))
# Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
### if e1:
# Rotation = rot(np.array([0,0,1]),-np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/16).dot(Rotation)
# Add another rotation around z-axis:
# Rotation = rot(np.array([0,0,1]),+np.pi).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/4).dot(Rotation)
# Rotation = rot(np.array([0,0,1]),+np.pi/8).dot(Rotation)
#e3 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2))
# Rotation = rot(np.array([0,0,1]),np.pi/4)
# Rotation = rot(np.array([1,0,0]),np.pi/4)
#### if e1 :
# Rotation = rot(np.array([0,1,0]),-np.pi/2)
#### if e2:
# Rotation = rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2))
# # #### if e3 :
# zufall dass np.pi/4 genau dem Winkel angle alpha entspricht?:
# (würde) bei e_2 keinen Unterschied machen um z achse zu rotieren?!
# Rotation = rot(np.array([0,0,1]),np.pi/4).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([0,0,1]),np.pi/2).dot(rot(np.array([0,1,0]),-np.pi/2).dot(rot(np.array([1,0,0]),-np.pi/2)))
# Rotation = rot(np.array([1,0,0]),np.pi/2)
# Rotation_vector = e3_mapped #TEST
# Rotation_vector = np.array([-1/np.sqrt(2),1/np.sqrt(2)])
# Rotation_vector = np.array([0,0,1])
# v = np.array([1,0,0])
# X = np.array([u1,u2,u3])
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 2, cstride = 2, facecolors=cm.brg(colorfunction), alpha=.4, zorder=4)
ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.Blues(colorfunction), alpha=.4, zorder=4)
###---- PLOT PARAMETER-PLANE:
# ax.plot_surface(x1,x2,zero,color = 'w', rstride = 1, cstride = 1 )
print('------------------ Kappa : ', kappa)
#midpoint:
midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
print('midpoint',midpoint)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
# mapped_e = Rotation.dot(mapped_e)
# normal = Rotation.dot(normal)
# Plot Mapped_midPoint
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=4) # line width
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [mapped_e[0]], [mapped_e[1]], [mapped_e[2]], color="red")
# ax.quiver([midpoint_mapped[0]], [midpoint_mapped[1]], [midpoint_mapped[2]], [normal[0]], [normal[1]], [normal[2]], color="blue")
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
mapped_e[0],mapped_e[1],mapped_e[2],
mutation_scale=15,
arrowstyle="-|>",
linestyle='dashed',fc='green',
lw = 2,
ec ='green',
zorder=3)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
normal[0],normal[1],normal[2],
mutation_scale=15,
lw = 2,
arrowstyle="-|>",
linestyle='dashed',fc='blue',
ec ='blue',
zorder = 3)
###-- TEST Rotation :
# v = np.array([1,0,0])
# t = np.array([0,1,0])
#
# ax.arrow3D(0,0,0,
# t[0],t[1],t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
#
# # e_extend
#
# rotM = rot(v,np.pi/2)
#
# print('rotM:', rotM)
#
# rot_t = rotM.dot(t)
#
# print('rot_t:', rot_t)
#
# ax.arrow3D(0,0,0,
# rot_t[0],rot_t[1],rot_t[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
### -------------------------------------------
############################################################################################################################################
####################################################################### KAPPA POSITIVE ####################################################
############################################################################################################################################
kappa = (-1)*kappa
# if kappa == 0 :
# u1 = 0*x1
# u2 = x1*e[0] + x2*e[1]
# u3 = x2*e[0] - x1*e[1]
# else :
# u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
# u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
# u3 = x2*e[0] -x1*e[1]
if kappa == 0 :
# u1 = 0*x1
# u2 = x1*e[0] + x2*e[1]
# u3 = x2*e[0] - x1*e[1]
u1 = x1*e[0] + x2*e[1]
u2 = x2*e[0] - x1*e[1]
u3 = 0*x1
else :
# u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
# u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
# u3 = x2*e[0] -x1*e[1]
u1 = -(1/kappa)*np.sin((-1)*kappa*(x1*e[0]+x2*e[1]))
u2 = x2*e[0] -x1*e[1]
u3 = (1/kappa)*np.cos((-1)*kappa*(x1*e[0]+x2*e[1]))-(1/kappa)
# ax.plot_surface(u1, u2, u3, color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.3) ##This one!
# T = rotate_data(X,Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=False)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, antialiased=True)
ax.plot_surface(T[0], T[1], T[2], rstride = 2, cstride = 2, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=.4, zorder=4, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'w', rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=0.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, facecolors=cm.autumn(colorfunction), alpha=1, zorde5r=5)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
# print('midpoint',midpoint)
print('------------------ Kappa : ', kappa)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
#map origin
origin = np.array([0,0])
origin_mapped = u(origin,kappa,e)
mapped_e = grad_u(midpoint,kappa,e)
normal = compute_normal(midpoint,kappa,e)
print('mapped_e', mapped_e)
print('normal',normal )
#
# mapped_e = Rotation.dot(mapped_e)
# normal = Rotation.dot(normal)
# ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', markersize=10,marker='o', zorder=5)
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
linewidth=1,
zorder=5) # line width
# ax.scatter3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], color='black', s=100, zorder=5)
# mapped_e = grad_u(midpoint,kappa,e)
# normal = compute_normal(midpoint,kappa,e)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
mapped_e[0],mapped_e[1],mapped_e[2],
mutation_scale=15,
arrowstyle="-|>",
linestyle='dashed',fc='green',
lw = 1.5,
ec ='green',
zorder=5)
ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
normal[0],normal[1],normal[2],
mutation_scale=15,
lw = 1.5,
arrowstyle="-|>",
linestyle='dashed',fc='blue',
ec ='blue',
zorder = 5)
############################################################################################################################################
####################################################################### KAPPA ZERO #########################################################
############################################################################################################################################
kappa = 0
# if kappa == 0 :
# u1 = 0*x1
# u2 = x1*e[0] + x2*e[1]
# u3 = x2*e[0] - x1*e[1]
# else :
# u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
# u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
# u3 = x2*e[0] -x1*e[1]
if kappa == 0 :
# u1 = 0*x1
# u2 = x1*e[0] + x2*e[1]
# u3 = x2*e[0] - x1*e[1]
u1 = x1*e[0] + x2*e[1]
u2 = x2*e[0] - x1*e[1]
u3 = 0*x1
else :
# u1 = -(1/kappa)*np.cos(kappa*(x1*e[0]+x2*e[1])) + (1/kappa)
# u2 = (1/kappa)*np.sin(kappa*(x1*e[0]+x2*e[1]))
# u3 = x2*e[0] -x1*e[1]
u1 = -(1/kappa)*np.sin((-1)*kappa*(x1*e[0]+x2*e[1]))
u2 = x2*e[0] -x1*e[1]
u3 = (1/kappa)*np.cos((-1)*kappa*(x1*e[0]+x2*e[1]))-(1/kappa)
# ax.plot_surface(u1, u2, u3, rstride = 1, cstride = 1, color = 'white', alpha=0.85)
# T = rotate_data(np.array([u1,u2,u3]),Rotation_vector,Rotation_angle)
T = rotate_data(np.array([u1,u2,u3]),Rotation)
# T = rotate_data(T,np.array([0,1,0]),Rotation_angle)
# T = rotate_data(T,np.array([0,0,1]),-1*Rotation_angle/2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2, antialiased=True)
# ax.plot_surface(T[0], T[1], T[2], rstride =1 , cstride = 1, color = 'white', alpha=0.55, zorder=3)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 1, cstride = 1, color = 'white', alpha=0.5, zorder=2, antialiased=True)
ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color = 'white', alpha=0.55, zorder=2)
# ax.plot_surface(T[0], T[1], T[2], rstride = 20, cstride = 20, color = 'gray', alpha=0.35, zorder=1, shade=True)
# ax.plot_surface(T[0], T[1], T[2], color = 'white', alpha=0.55, zorder=2)
# midpoint = np.array([(max(x)+min(x))/2,(max(y)+min(y))/2])
mapped_e = grad_u(midpoint,kappa,e)
normal_zeroCurv = compute_normal(midpoint,kappa,e)
# Map midpoint:
midpoint_mapped = u(midpoint,kappa,e)
print('mapped midpoint', midpoint_mapped)
##----- PLOT MAPPED MIDPOINT :::
ax.plot(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=4, # marker size
markerfacecolor='orange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=1, # marker edge width
# linestyle='--', # line style will be dash line
linewidth=1,
zorder=5)
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# mapped_e[0],mapped_e[1],mapped_e[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='red',
# ec ='red')
#
# ax.arrow3D(midpoint_mapped[0],midpoint_mapped[1],midpoint_mapped[2],
# normal_zeroCurv[0],normal_zeroCurv[1],normal_zeroCurv[2],
# mutation_scale=10,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue')
##---------- PLOT MAPPED ORIGIN :::
# origin = np.array([0,0])
# origin_mapped = u(origin,kappa,e)
# print('origin_mapped', origin_mapped)
#
# ax.plot(origin_mapped[0],origin_mapped[1],origin_mapped[2], # data
# marker='o', # each marker will be rendered as a circle
# markersize=4, # marker size
# markerfacecolor='green', # marker facecolor
# markeredgecolor='black', # marker edgecolor
# markeredgewidth=1, # marker edge width
# linewidth=1,
# zorder=5) # line width
#
# # rotate mapped origin
# # v = np.array([1,0,0])
# # alpha = Rotation_angle
#
# rotM = rot(Rotation_vector,Rotation_angle)
# # origin_mRot = rotate_data(origin_mapped,v,alpha)
# origin_mRot = rotM.dot(origin_mapped)
# print('origin_mapped Rotated', origin_mRot)
#
# # --- Compute Distance to Origin 3D
# origin_3D=np.array([0,0,0])
# distance = origin_mapped-origin_3D
# print('distance', distance)
## --------------------------------------------------------
# COMPUTE ANGLE WITH Z AXIS
z = np.array([0,0,1])
print('test', normal_zeroCurv*z)
angle_z = np.arccos(normal_zeroCurv.dot(z) /( (np.linalg.norm(z)*np.linalg.norm(normal_zeroCurv) ) ))
print('angle between normal and z-axis', angle_z)
## unfinished...
###------------------------------------- PLOT :
plt.axis('off')
# plt.axis('tight')
# ADD colorbar
# scamap = plt.cm.ScalarMappable(cmap='inferno')
# fig.colorbar(scamap)
# ax.colorbar()
# ax.axis('auto')
# ax.set_title(r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e))
# ax.set_title(r'Cylindrical minimizer' + '_$e$=' + str(e))
ax.set_xlabel(r"x-axis")
ax.set_ylabel(r"y-axis")
ax.set_zlabel(r"z-axis")
# TEST :
# ax.annotate3D('point 1', (0, 0, 0), xytext=(3, 3), textcoords='offset points')
# ax.annotate3D('point 2', (0, 1, 0),
# xytext=(-30, -30),
# textcoords='offset points',
# arrowprops=dict(ec='black', fc='white', shrink=2.5))
# ax.annotate3D('point 3', (0, 0, 1),
# xytext=(30, -30),
# textcoords='offset points',
# bbox=dict(boxstyle="round", fc="lightyellow"),
# arrowprops=dict(arrowstyle="-|>", ec='black', fc='white', lw=5))
#######################################################################################################################
u1 = T[0]
u2 = T[1]
u3 = T[2]
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /3
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /2
mid_u1 = (u1.max()+u1.min()) * 0.5
mid_u2 = (u2.max()+u2.min()) * 0.5
mid_u3 = (u3.max()+u3.min()) * 0.5
ax.set_xlim(mid_u1 - max_range, mid_u1 + max_range)
ax.set_ylim(mid_u2 - max_range, mid_u2 + max_range)
ax.set_zlim(mid_u3 - max_range, mid_u3 + max_range)
##----- CHANGE CAMERA POSITION:
# ax.view_init(elev=10., azim=0)
# ax.view_init(elev=38, azim=90)
# ax.view_init(elev=38, azim=120)
# ax.view_init(elev=38)
# if e1 ::
# ax.view_init(elev=44)
# ax.view_init(elev=38, azim=-90)
# ax.view_init(elev=38, azim=0)
# if e3 ::
ax.view_init(elev=25)
# ax.set_xlim3d(-2, 2)
# ax.set_ylim3d(-1.0,3.0)
# ax.set_zlim3d(-1.5,2.5)
# ax.set_ylim3d(-10,10)
# ax.set_xlim(mid_u1 - max_range-0.2, mid_u1 + max_range+0.2)
# ax.set_zlim(mid_u3 - max_range-0.2, mid_u3 + max_range+0.2)
# ax.set_ylim(mid_u2 - max_range-0.2, mid_u2 + max_range+0.2)
# width = 6.28 *0.5
# height = width / 1.618
# # height = width / 2.5
# fig.set_size_inches(width, height)
# fig.savefig('Test-Cylindrical.pdf')
# Figurename = r'Cylindrical minimizer_$\kappa$='+ str(kappa)+ '_$e$=' + str(e)
Figurename = r'Cylindrical minimizer' + '_$e$=' + str(e)
# plt.savefig("test.png", bbox_inches='tight')
# plt.figure().set_size_inches(width, height)
# plt.set_size_inches(width, height)
# fig.set_size_inches(width, height)
# fig.savefig(Figurename+".pdf")
plt.savefig(Figurename+".png", bbox_inches='tight')
# plt.savefig(Figurename+".png")
plt.show()
# #---------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
mu1 = 1.0
rho1 = 1.0
alpha = 5.0
theta = 1.0/2
# theta= 0.1
beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
gamma = 'infinity'
lambda1 = 0.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
# print('alpha: ', alpha)
print('beta: ', beta)
# print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
q12 = 0.0
q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
b1 = prestrain_b1(rho1,beta, alpha, theta )
b2 = prestrain_b2(rho1,beta, alpha, theta )
# 1-ParameterFamilyCase:
q1=1;
q2=2;
q12=1/2;
q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 400
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
geyser = sns.load_dataset("geyser")
print('type of geyser:', type(geyser))
print('geyser:',geyser)
ContourRange=20
x_in = np.linspace(-ContourRange,ContourRange,num_Points)
y_in = np.linspace(-ContourRange,ContourRange,num_Points)
a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
#
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "9"
label_size = 8
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
# plt.style.use('seaborn')
plt.style.use('seaborn-whitegrid')
# sns.set()
# plt.style.use('seaborn-whitegrid')
label_size = 9
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
width = 6.28 *0.5
# width = 6.28
height = width / 1.618
fig = plt.figure()
# ax = plt.axes(projection ='3d', adjustable='box')
ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
Z = Z-c
print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.5,))
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
ax.clabel(CS, inline=True, fontsize=4)
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
# cmap=mpl.cm.viridis_r
cmap=mpl.cm.bwr
# cmap=mpl.cm.coolwarm
cmap=mpl.cm.gnuplot
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
cmap=cmap, alpha=0.6)
# COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=8)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.1
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color='gray', zorder=5)#yellow
ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color='gray', zorder=5)#yellow
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.set_xlabel(r"$a_1$", fontsize=10 ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=10 ,labelpad=0)
# ax.set_ylabel(r"energy")
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# ax.legend(loc='upper right')
fig.set_size_inches(width, height)
fig.savefig('Energy_ContourG+.pdf')
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from chart_studio import plotly
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import plotly.io as pio
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
def show(fig):
import io
import plotly.io as pio
from PIL import Image
buf = io.BytesIO()
pio.write_image(fig, buf)
img = Image.open(buf)
img.show()
def set_size(width, fraction=1):
"""Set figure dimensions to avoid scaling in LaTeX.
Parameters
----------
width: float
Document textwidth or columnwidth in pts
fraction: float, optional
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure (in pts)
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
# https://disq.us/p/2940ij3
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
mu1 = 1.0
rho1 = 1.0
alpha = 5.0
theta = 1.0/2
# theta= 0.1
beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
gamma = 'infinity'
lambda1 = 0.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
# print('alpha: ', alpha)
print('beta: ', beta)
# print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
q12 = 0.0
q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
b1 = prestrain_b1(rho1,beta, alpha, theta )
b2 = prestrain_b2(rho1,beta, alpha, theta )
# 1-ParameterFamilyCase:
q1=1;
q2=2;
q12=1/2;
q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
# num_Points = 400
num_Points = 100
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
geyser = sns.load_dataset("geyser")
print('type of geyser:', type(geyser))
print('geyser:',geyser)
ContourRange=20
x_in = np.linspace(-ContourRange,ContourRange,num_Points)
y_in = np.linspace(-ContourRange,ContourRange,num_Points)
a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
#
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
tmp1 = a1[a1*a2 >= 0]
tmp2 = a2[a1*a2 >= 0]
tmp1 = tmp1.reshape(-1,5)
tmp2 = tmp2.reshape(-1,5)
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
#
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
#
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
#
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "9"
label_size = 8
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
# plt.style.use('seaborn')
# plt.style.use('seaborn-whitegrid')
# sns.set()
# plt.style.use('seaborn-whitegrid')
label_size = 9
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
width = 6.28 *0.5
width = 6.28 *0.33
# width = 6.28
height = width / 1.618
height = width
fig = plt.figure()
# ax = plt.axes(projection ='3d', adjustable='box')
ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
Z = Z-c
print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.5,),zorder=5)
## PLOTLY:
fig = make_subplots(specs=[[{"secondary_y": True}]])
data1 = go.Contour(x = x_in, y = y_in, z = Z_in,
# colorscale='Electric',
colorscale='agsunset',
contours=dict(
coloring ='heatmap',
showlabels = True, # show labels on contours
labelfont = dict( # label font properties
size = 14,
color = 'white',
)
), line_width=2 ,line_smoothing=0.85,
# colorbar=dict(
# title='Color bar title', # title here
# titleside='right',
# titlefont=dict(
# size=14,
# family='Arial, sans-serif')
# )
)
epsilon = 0.4
epsilon = 0.1
# data2 = go.Scatter(x=[0+epsilon,x.max(),x.max(), 0+epsilon], y=[0-epsilon,0-epsilon,y.min(),y.min()], fill="toself")
data2 = go.Scatter(x=[0+epsilon,x.max(),x.max(), 0+epsilon], y=[0-epsilon,0-epsilon,y.min(),y.min()])
# data_tmp = [data1,data2]
data_tmp = [data1]
fig = go.Figure(data = data_tmp)
# ADD RECTANGLES:
fig.add_shape(type="rect",
x0=0+epsilon, y0=0-epsilon, x1=x.max(), y1=y.min(),
line=dict(
color="White",
width=1,
),
fillcolor="White",
opacity=0.75
)
fig.add_shape(type="rect",
x0=x.min(), y0=0+epsilon, x1=0-epsilon, y1=y.max(),
line=dict(
color="White",
width=1
),
fillcolor="White",
opacity=0.75
)
# ADD COORDINATE LINES
fig.add_shape(type="line",
x0=x.min(), y0=0, x1=x.max(), y1=0,
line=dict(
color="black",
width=2,
dash="dash",
)
)
fig.add_shape(type="line",
x0=0, y0=y.min(), x1=0, y1=y.max(),
line=dict(
color="black",
width=2,
dash="dash",
)
)
# fig = go.Figure(data = go.Contour(Z_in, a1_in, a2_in))
# fig = go.Figure(data = go.Contour(x = x_in, y = y_in, z = Z_in,
# # colorscale='Electric',
# colorscale='agsunset',
# contours=dict(
# coloring ='heatmap',
# showlabels = True, # show labels on contours
# labelfont = dict( # label font properties
# size = 12,
# color = 'white',
# )
# ), line_width=2 ,line_smoothing=0.85,
# # colorbar=dict(
# # title='Color bar title', # title here
# # titleside='right',
# # titlefont=dict(
# # size=14,
# # family='Arial, sans-serif')
# # )
# )
# )
epsilon = 0.4
epsilon = 0.1
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
# fillcolor = 'white'
# ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
# trace2 = go.Figure(go.Scatter(x=[0+epsilon,x.max(),x.max(), 0+epsilon], y=[0-epsilon,0-epsilon,y.min(),y.min()], fill="toself"))
# fig.add_trace(trace1)
# fig.add_trace(trace1)
# fig.add_trace(trace2.data[0],secondary_y=True)
fig.update_layout(
autosize=False,
# width=500,
# height=500,
width=300,
height=300,
# margin=dict(
# l=50,
# r=50,
# b=100,
# t=100,
# pad=4
# ),
# paper_bgcolor="LightSteelBlue",
)
width = 452.9579/2
size= set_size(width, fraction=0.5)
print('set_size(width, fraction=0.5)', set_size(width, fraction=0.5))
print('size[0]',size[0])
# fig.show()
# show(fig)
# fig.write_image("Plotly-fig1.png", width=width, height=height, scale=1)
fig.write_image("Plotly-fig1.png")
# pio.write_image(fig, "test.svg", width=6.28 *0.33*300, height=6.28 *0.33*300, scale=1)
# pio.write_image(fig, "test.png", width=6.28*0.33*300, height=6.28*0.33*300)
pio.write_image(fig, "test.pdf", width=6.28*0.33*300, height=6.28*0.33*300)
# pio.write_image(fig, "test.pdf", width=width, height=width)
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
ax.clabel(CS, inline=True, fontsize=4)
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
# cmap=mpl.cm.viridis_r
cmap=mpl.cm.bwr
# cmap=mpl.cm.coolwarm
cmap=mpl.cm.gnuplot
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
cmap=cmap, alpha=0.6)
# COLORBAR :
cbar = plt.colorbar()
cbar.ax.tick_params(labelsize=8)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.1
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
fillcolor = 'white'
ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.set_xlabel(r"$a_1$", fontsize=10 ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=10 ,labelpad=0)
# ax.set_ylabel(r"energy")
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# ax.legend(loc='upper right')
fig.set_size_inches(width, height)
fig.savefig('Energy_ContourG+.pdf')
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from chart_studio import plotly
import plotly.graph_objs as go
import plotly.express as px
import plotly.colors
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
def show(fig):
import io
import plotly.io as pio
from PIL import Image
buf = io.BytesIO()
pio.write_image(fig, buf)
img = Image.open(buf)
img.show()
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def set_size(width, fraction=1):
"""Set figure dimensions to avoid scaling in LaTeX.
Parameters
----------
width: float
Document textwidth or columnwidth in pts
fraction: float, optional
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure (in pts)
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
# https://disq.us/p/2940ij3
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def check_case(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = inv_H.dot(tmp)
print('g_star=', g_star)
return g_star
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
mu1 = 1.0
rho1 = 1.0
alpha = 5.0
theta = 1.0/2
# theta= 0.1
beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = -0.75
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
# gamma = 'infinity'
lambda1 = 0.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
# print('alpha: ', alpha)
print('beta: ', beta)
# print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
q12 = 0.0
q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
b1 = prestrain_b1(rho1,beta, alpha, theta )
b2 = prestrain_b2(rho1,beta, alpha, theta )
## ---- 1-ParameterFamilyCase:
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
# print('abar:',abar)
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
# b1=b[0]
# b2=b[1]
## ---------------
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
## --- CHECK CASE ---
g_star = check_case(q1,q2,q12,q3,b1,b2)
## -------------------------------------
num_Points = 400
num_Points = 200
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
x = np.linspace(-2,2,num_Points)
y = np.linspace(-2,2,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
# geyser = sns.load_dataset("geyser")
# print('type of geyser:', type(geyser))
# print('geyser:',geyser)
# ContourRange=20
ContourRange=2
x_in = np.linspace(-ContourRange,ContourRange,num_Points)
y_in = np.linspace(-ContourRange,ContourRange,num_Points)
a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
#
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
tmp1 = a1[a1*a2 >= 0]
tmp2 = a2[a1*a2 >= 0]
tmp1 = tmp1.reshape(-1,5)
tmp2 = tmp2.reshape(-1,5)
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
#
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
#
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
#
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "9"
label_size = 8
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
# plt.style.use('seaborn')
# plt.style.use('seaborn-whitegrid')
# sns.set()
# plt.style.use('seaborn-whitegrid')
label_size = 9
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
width = 6.28 *0.5
# width = 6.28 *0.33
# width = 6.28
height = width #/ 1.618
# width = 452.9579/2
# size= set_size(width, fraction=0.5)
# print('set_size(width, fraction=0.5)', set_size(width, fraction=1))
# print('size[0]',size[0])
f_size = 8
# fig= plt.figure()
fig, ax = plt.subplots()
# fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.5))
# ax = plt.axes(projection ='3d', adjustable='box')
# ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.17,0.23 ,0.7,0.7))
# ax = plt.axes((0.17,0.23 ,1.0,1.0))
# ax=plt.axes()
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
# c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
# Z = Z-c
#
# print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75) ,zorder=5)
step = (-1)*Z.min()
levels = np.arange(Z.min(),Z.max()/2,step)
levels = np.arange(Z.min(),Z.max()/12,step)
# levels = np.arange(0,Z.max()/2,200)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
# ax.clabel(CS, inline=True, fontsize=4)
# ax.clabel(CS, inline=True, fontsize=4)
# 1- ParameterFAMILY CASE :
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ),(-12.5,-12.5),(-14,-14), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
# GAMMA = inf
manual_locations = [
(1, 1), (-5, -5), (-10, -10 ), (-15,-15),
(5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
#
#
# # GAMMA = 0
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15), (-15,7),
# (5, 5), (10, 10 ), (15,15), (17,17)]
# ax.clabel(CS, inline=True, fontsize=f_size, colors='black', manual=manual_locations)
ax.clabel(CS, inline=True, fontsize=f_size, colors='black')
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
cmap=mpl.cm.viridis_r
# cmap=mpl.cm.bwr
cmap=mpl.cm.coolwarm
# cmap=mpl.cm.gnuplot
cmap=mpl.cm.magma_r
# cmap=mpl.cm.inferno_r
# cmap=mpl.cm.plasma
# cmap=mpl.cm.plasma_r
# cmap=mpl.cm.cividis_r
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", [(0,"red"), (.1,"violet"), (.5, "blue"), (1.0, "green")])
# make a colormap that has land and ocean clearly delineated and of the
# same length (256 + 256)
#
# colors_undersea = plt.cm.terrain(np.linspace(0, 0.17, 256))
# colors_land = plt.cm.terrain(np.linspace(0.25, 1, 256))
# all_colors = np.vstack((colors_undersea, colors_land))
# # cmap = mcolors.LinearSegmentedColormap.from_list(
# # 'terrain_map', all_colors)
# cmap = px.colors.sequential.agsunset
# cmap = plotly.colors.PLOTLY_SCALES["Viridis"]
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=(Z.max()+Z.min())/2, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-500, vcenter=0, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0. ,vmax=10)
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0., vmax=Z.max())
# divnorm=mcolors.LogNorm(vmin=Z.min(), vmax=Z.max()) #Test LogNorm
# cmap = cm.brg(divnorm(Z))
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
cmap=cmap, alpha=0.9)
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = mcolors.CenteredNorm(),
# cmap=cmap, alpha=0.6)
# COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=f_size)
# fig.colorbar(I)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.2
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
fillcolor = 'white'
# ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=1.0, color=fillcolor, zorder=4)#yellow
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.scatter(g_star[0],g_star[1], s=20, zorder=5)
ax.text(g_star[0]+1,g_star[1]-1, r"$g_*$", color='royalblue', size=15, zorder = 5)
ax.set_xlabel(r"$a_1$", fontsize=f_size ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=f_size ,labelpad=0)
# ax.set_ylabel(r"energy")
ax.tick_params(axis='both', which='major', labelsize=f_size)
ax.tick_params(axis='both', which='minor', labelsize=f_size)
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# ax.legend(loc='upper right')
fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.33))
fig.savefig('Energy_ContourG+.pdf')
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from chart_studio import plotly
import plotly.graph_objs as go
import plotly.express as px
import plotly.colors
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
def show(fig):
import io
import plotly.io as pio
from PIL import Image
buf = io.BytesIO()
pio.write_image(fig, buf)
img = Image.open(buf)
img.show()
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def set_size(width, fraction=1):
"""Set figure dimensions to avoid scaling in LaTeX.
Parameters
----------
width: float
Document textwidth or columnwidth in pts
fraction: float, optional
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure (in pts)
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
# https://disq.us/p/2940ij3
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def check_case(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
print('g_star=', g_star)
return g_star
def get_gstar(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
# print('g_star=', g_star)
return g_star
def determine_b(q1,q2,q12,q3,g_star):
##
# Input: g_star
# Output : b such that g_star is minimizer, i.e A*b = (1/2)*H*g_star
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
rhs = (1/2)*H.dot(g_star)
print('rhs:', rhs)
b = np.linalg.lstsq(A, rhs)[0]
print('b',b)
b1=b[0]
b2=b[1]
return b
## ---------------
def get_minimizer(q1,q2,q3,b1,b2):
# In the case if q12 == 0:
quotient = (q1*q2-q3**2)
g_star = np.array([(q1*q2*b1-q3*q2*b2)/quotient, (q1*q2*b2-q3*q1*b1)/quotient])
print('g_star=', g_star)
return g_star
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
def draw_1ParameterLine(q1,q2,q12,q3):
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
# print('abar:',np.shape(abar))
# print('np.transpose(abar):',np.shape(np.transpose(abar)))
sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# sstar = (1/(q1+q2))*abar.dot(tmp)
print('sstar', sstar)
abarperp= np.array([abar[1],-abar[0]])
print('abarperp:',abarperp)
N=500;
scale_domain = 5
translate_startpoint = -1.8
scale_domain = 4.65
translate_startpoint = -1.85
# --- FUll LINE:
scale_domain = 4.5
translate_startpoint = -1.4
T_line = np.linspace(-sstar*(q12+2*q3)/(2*q2)*scale_domain + translate_startpoint, sstar*(2*q2)/(q12+2*q3)*scale_domain , num=N)
line_values = []
for t in T_line :
print('sstar*abar+t*abarperp', sstar*abar+t*abarperp)
line_values.append(sstar*abar+t*abarperp)
# ------
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
# T = np.linspace(-sstar*(q12+2*q3)/(2*q2)*scale_domain + translate_startpoint, sstar*(2*q2)/(q12+2*q3)*scale_domain , num=N)
# T = np.linspace(-2,2, num=N)
# print('T:', T)
print('T.min():', T.min())
print('T.max():', T.max())
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
abar_tmp = abar
for t in T :
abar_current = sstar*abar+t*abarperp;
abar_current[abar_current < 1e-10] = 0 # Project to x-y-axis!!
current_energy = energy(abar_current[0],abar_current[1],q1,q2,q12,q3,b1,b2)
print('energy along line:', current_energy )
G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
G_container.append(G)
abar_container.append(abar_current)
e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
kappas.append(kappa)
alphas.append(alpha)
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('G_container', G_container)
G = np.array(G_container)
abar = np.array(abar_container)
# print('G', G)
# print('abar', abar)
# print('abar.shape',abar.shape)
line = ax.plot(abar[:,0],abar[:,1], linewidth=2, color='royalblue', linestyle='-', zorder=4)
# Plot 1-Parameter Line
line_values= np.array(line_values)
ax.plot(line_values[:,0],line_values[:,1],'k--', linewidth=1,color='royalblue',alpha=0.8,zorder=4)
return line
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = 5.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = -0.75
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
# gamma = '0'
# # gamma = 'infinity'
#
#
# lambda1 = 0.0
print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# # print('alpha: ', alpha)
# print('beta: ', beta)
# # print('theta: ', theta)
# print('gamma:', gamma)
#
# print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
# q12 = 0.0
# q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, alpha, theta )
# b2 = prestrain_b2(rho1,beta, alpha, theta )
#
case = 'a'
case = 'b'
case = 'c'
if case == 'a':
print('---- CASE (a) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([0,1])
g_star = np.array([-1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'b':
print('---- CASE (b) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'c':
print('---- CASE (c) ----')
## ---- 1-ParameterFamilyCase:
q1=1;
q2=2;
q12=1/2;
q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
## ---------------
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
## --- CHECK CASE ---
if case == 'a':
# Check Minimizers:
vec1 = np.array([(2*q1*b1+q12*b2)/(2*q1), 0])
vec2 = np.array([0, (2*q12*b1+q2*b2)/(2*q2)])
print('vec1:',vec1)
print('vec2:',vec2)
energy_1 = energy(vec1[0],vec1[1],q1,q2,q12,q3,b1,b2)
energy_2 = energy(vec2[0],vec2[1],q1,q2,q12,q3,b1,b2)
print('energy_1:',energy_1)
print('energy_2:',energy_2)
if energy_1 >= energy_2:
minvec = vec2
else:
minvec = vec1
print('minvec:', minvec)
check_case(q1,q2,q12,q3,b1,b2)
g_star = get_gstar(q1,q2,q12,q3,b1,b2)
print('g_star:',g_star)
# TEST
print('special case g_star:')
get_minimizer(q1,q2,q3,b1,b2)
## -------------------------------------
num_Points = 400
# num_Points = 600
# num_Points = 200
# num_Points = 100
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
x = np.linspace(-2,2,num_Points)
y = np.linspace(-2,2,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
# geyser = sns.load_dataset("geyser")
# print('type of geyser:', type(geyser))
# print('geyser:',geyser)
# ContourRange=20
ContourRange=2
# x_in = np.linspace(-ContourRange,ContourRange,num_Points)
# y_in = np.linspace(-ContourRange,ContourRange,num_Points)
# a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
#
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
tmp1 = a1[a1*a2 >= 0]
tmp2 = a2[a1*a2 >= 0]
tmp1 = tmp1.reshape(-1,5)
tmp2 = tmp2.reshape(-1,5)
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
#
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
#
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
# Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "9"
label_size = 8
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
# plt.style.use('seaborn')
# plt.style.use('seaborn-whitegrid')
# sns.set()
# plt.style.use('seaborn-whitegrid')
label_size = 9
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
width = 6.28 *0.5
# width = 6.28 *0.33
# width = 6.28
height = width #/ 1.618
# width = 452.9579/2
# size= set_size(width, fraction=0.5)
# print('set_size(width, fraction=0.5)', set_size(width, fraction=1))
# print('size[0]',size[0])
f_size = 10
# fig= plt.figure()
fig, ax = plt.subplots()
# fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.5))
# ax = plt.axes(projection ='3d', adjustable='box')
# ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.17,0.23 ,0.7,0.7))
# ax = plt.axes((0.17,0.23 ,1.0,1.0))
# ax=plt.axes()
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
# c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
# Z = Z-c
#
# print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75) ,zorder=5)
step = (-1)*Z.min()
# step = 3.0
levels = np.arange(Z.min(),Z.max()/2,step)
# evels = np.arange(-4, 25, 4)
# levels = np.arange(-3, 23, 4)
# levels = np.arange(Z.min(),Z.max()/12,step)
# levels = np.arange(Z.min(),Z.max(),step)
# levels = np.arange(0,Z.max()/2,200)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
if case == 'b':
levels = np.arange(-4, 25, 4)
if case == 'a':
levels = np.arange(-1, 25, 5) # if g_star = [0 1]
levels = np.arange(0, 24, 4) # if g_star = [-1 1]
if case == 'c':
levels = np.arange(0, 25, 4)
CS = ax.contour(a1, a2, Z,levels, colors='k',linewidths=(0.75), extent=(-2, 2, -2, 2), zorder=5)
# CS = ax.contour(a1 , a2 , Z, colors='k', linewidths=(0.75), zorder=5)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
# ax.clabel(CS, inline=True, fontsize=4)
# ax.clabel(CS, inline=True, fontsize=4)
# 1- ParameterFAMILY CASE :
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ),(-12.5,-12.5),(-14,-14), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
if case == 'c':
manual_locations = [
(1, 1), (0.5, 0.5),(1.5,1.5),(1.75,1.75),(-0.2,0.2), (-0.5,-0.5),
(-1,-1),(-1.25,-1.25), (-1.5,-1.5)]
ax.clabel(CS, inline=True, fontsize=9, colors='black', manual=manual_locations)
else :
ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# GAMMA = inf
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
#
#
# # GAMMA = 0
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15), (-15,7),
# (5, 5), (10, 10 ), (15,15), (17,17)]
# ax.clabel(CS, inline=True, fontsize=f_size, colors='black')
# ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
cmap=mpl.cm.viridis_r
# cmap=mpl.cm.bwr
cmap=mpl.cm.coolwarm
# cmap=mpl.cm.gnuplot
cmap=mpl.cm.magma_r
# cmap=mpl.cm.inferno_r
# cmap=mpl.cm.plasma
# cmap=mpl.cm.plasma_r
# cmap=mpl.cm.cividis_r
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", [(0,"red"), (.1,"violet"), (.5, "blue"), (1.0, "green")])
# make a colormap that has land and ocean clearly delineated and of the
# same length (256 + 256)
#
# colors_undersea = plt.cm.terrain(np.linspace(0, 0.17, 256))
# colors_land = plt.cm.terrain(np.linspace(0.25, 1, 256))
# all_colors = np.vstack((colors_undersea, colors_land))
# # cmap = mcolors.LinearSegmentedColormap.from_list(
# # 'terrain_map', all_colors)
# cmap = px.colors.sequential.agsunset
# cmap = plotly.colors.PLOTLY_SCALES["Viridis"]
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=(Z.max()+Z.min())/2, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-500, vcenter=0, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0. ,vmax=10)
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0., vmax=Z.max())
# divnorm=mcolors.LogNorm(vmin=Z.min(), vmax=Z.max()) #Test LogNorm
# cmap = cm.brg(divnorm(Z))
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
cmap=cmap, alpha=0.9)
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = mcolors.CenteredNorm(),
# cmap=cmap, alpha=0.6)
# COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=f_size)
# fig.colorbar(I)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.2
epsilon = 0.005
epsilon = 0.01
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
fillcolor = 'white'
# ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
ax.fill_between([0+epsilon, x.max()-epsilon], y.min()+epsilon, 0-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
ax.fill_between([x.min()+epsilon, 0-epsilon], 0+epsilon, y.max()-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
if case == 'a':
# PLOT MINIMIZER g*:
# ax.scatter(g_star[0],g_star[1], s=20, zorder=5)
# ax.scatter(g_star[0],g_star[1], marker = 'x', s=20, zorder=5)
# ax.text(g_star[0]+0.1,g_star[1]-0.1, r"$g_*$", color='royalblue', size=15, zorder = 5)
ax.scatter(g_star[0],g_star[1], marker = 'x', s=40, color='gray', zorder=4)
ax.text(g_star[0]+0.15,g_star[1]-0.15, r"$g_*$", color='gray', size=12, alpha=0.8, zorder = 5)
if case == 'b':
# PLOT MINIMIZER g*:
ax.scatter(g_star[0],g_star[1], s=20, color='royalblue', zorder=5)
ax.scatter(g_star[0],g_star[1], marker = 'x', s=40, color='gray', zorder=4)
ax.text(g_star[0]+0.15,g_star[1]-0.15, r"$g_*$", color='gray', size=12, alpha=0.8, zorder = 5)
if case == 'c':
print('draw Line')
line = draw_1ParameterLine(q1,q2,q12,q3)
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
if case == 'c':
# draw MINIMAL VALUES
print('np.where(Z == Z.min())',np.where(np.round(Z,6) == np.round(Z.min(),6)))
tmp_x = a1[np.where(np.round(Z,6) == np.round(Z.min(),6))]
tmp_y = a2[np.where(np.round(Z,6) == np.round(Z.min(),6))]
# ax.scatter(tmp_x,tmp_y,color='red', zorder=5, s=1)
# ax.plot(tmp_x,tmp_y,color='forestgreen', zorder=5)
# print('np.where(Z == Z.min())',np.where(np.round(Z,8) == np.round(Z.min(),8)))
if case == 'a':
ax.scatter(minvec[0],minvec[1],color='royalblue',zorder=5, s=20)
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5, zorder=4)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5, zorder=4)
ax.set_xlabel(r"$a_1$", fontsize=f_size ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=f_size ,labelpad=0)
# ax.set_xlabel(r"$a_1$", fontsize=f_size )
# ax.set_ylabel(r"$a_2$", fontsize=f_size )
# ax.set_ylabel(r"energy")
ax.tick_params(axis='both', which='major', labelsize=f_size)
ax.tick_params(axis='both', which='minor', labelsize=f_size)
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# plt.subplots_adjust(left = 0.25 )
# ax.legend(loc='upper right')
fig.subplots_adjust(left=.18, bottom=.12, right=.90, top=.97)
fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.33))
Outputname = 'Energy_ContourG+_case'+ str(case) + '.pdf'
fig.savefig(Outputname)
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from chart_studio import plotly
import plotly.graph_objs as go
import plotly.express as px
import plotly.colors
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
def show(fig):
import io
import plotly.io as pio
from PIL import Image
buf = io.BytesIO()
pio.write_image(fig, buf)
img = Image.open(buf)
img.show()
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def set_size(width, fraction=1):
"""Set figure dimensions to avoid scaling in LaTeX.
Parameters
----------
width: float
Document textwidth or columnwidth in pts
fraction: float, optional
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure (in pts)
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
# https://disq.us/p/2940ij3
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def check_case(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
print('g_star=', g_star)
return g_star
def determine_b(q1,q2,q12,q3,g_star):
##
# Input: g_star
# Output : b such that g_star is minimizer, i.e A*b = (1/2)*H*g_star
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
rhs = (1/2)*H.dot(g_star)
print('rhs:', rhs)
b = np.linalg.lstsq(A, rhs)[0]
print('b',b)
b1=b[0]
b2=b[1]
return b
## ---------------
def get_minimizer(q1,q2,q3,b1,b2):
# In the case if q12 == 0:
quotient = (q1*q2-q3**2)
g_star = np.array([(q1*q2*b1-q3*q2*b2)/quotient, (q1*q2*b2-q3*q1*b1)/quotient])
print('g_star=', g_star)
return g_star
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
def draw_1ParameterLine(q1,q2,q12,q3):
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
# print('abar:',np.shape(abar))
# print('np.transpose(abar):',np.shape(np.transpose(abar)))
sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# sstar = (1/(q1+q2))*abar.dot(tmp)
print('sstar', sstar)
abarperp= np.array([abar[1],-abar[0]])
print('abarperp:',abarperp)
N=500;
scale_domain = 5
translate_startpoint = -1.8
scale_domain = 4.65
translate_startpoint = -1.85
# T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
T = np.linspace(-sstar*(q12+2*q3)/(2*q2)*scale_domain + translate_startpoint, sstar*(2*q2)/(q12+2*q3)*scale_domain , num=N)
# T = np.linspace(-2,2, num=N)
# print('T:', T)
print('T.min():', T.min())
print('T.max():', T.max())
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
abar_tmp = abar
for t in T :
abar_current = sstar*abar+t*abarperp;
# print('abar_current', abar_current)
abar_current[abar_current < 1e-10] = 0
# print('abar_current', abar_current)
# G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
# print('type of G', type(G))
# print('G', G)
G_container.append(G)
abar_container.append(abar_current)
e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('G_container', G_container)
G = np.array(G_container)
abar = np.array(abar_container)
# print('G', G)
# print('abar', abar)
# print('abar.shape',abar.shape)
line = ax.plot(abar[:,0],abar[:,1], linewidth=2, color='royalblue', linestyle='-', zorder=4)
return line
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = 5.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = -0.75
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
# gamma = '0'
# # gamma = 'infinity'
#
#
# lambda1 = 0.0
print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# # print('alpha: ', alpha)
# print('beta: ', beta)
# # print('theta: ', theta)
# print('gamma:', gamma)
#
# print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
# q12 = 0.0
# q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, alpha, theta )
# b2 = prestrain_b2(rho1,beta, alpha, theta )
#
case = 'a'
# case = 'b'
case = 'c'
if case == 'a':
print('---- CASE (a) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([0,1])
g_star = np.array([-1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'b':
print('---- CASE (b) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'c':
print('---- CASE (c) ----')
## ---- 1-ParameterFamilyCase:
q1=1;
q2=2;
q12=1/2;
q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
## ---------------
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
## --- CHECK CASE ---
g_star = check_case(q1,q2,q12,q3,b1,b2)
print('g_star:',g_star)
# TEST
print('special case g_star:')
get_minimizer(q1,q2,q3,b1,b2)
## -------------------------------------
num_Points = 400
num_Points = 600
num_Points = 200
# num_Points = 100
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
x = np.linspace(-2,2,num_Points)
y = np.linspace(-2,2,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
# geyser = sns.load_dataset("geyser")
# print('type of geyser:', type(geyser))
# print('geyser:',geyser)
# ContourRange=20
ContourRange=2
# x_in = np.linspace(-ContourRange,ContourRange,num_Points)
# y_in = np.linspace(-ContourRange,ContourRange,num_Points)
# a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
#
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
tmp1 = a1[a1*a2 >= 0]
tmp2 = a2[a1*a2 >= 0]
tmp1 = tmp1.reshape(-1,5)
tmp2 = tmp2.reshape(-1,5)
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
#
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
#
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
# Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "9"
label_size = 8
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
# plt.style.use('seaborn')
# plt.style.use('seaborn-whitegrid')
# sns.set()
# plt.style.use('seaborn-whitegrid')
label_size = 9
mpl.rcParams['xtick.labelsize'] = label_size
mpl.rcParams['ytick.labelsize'] = label_size
width = 6.28 *0.5
# width = 6.28 *0.33
# width = 6.28
height = width #/ 1.618
# width = 452.9579/2
# size= set_size(width, fraction=0.5)
# print('set_size(width, fraction=0.5)', set_size(width, fraction=1))
# print('size[0]',size[0])
f_size = 10
# fig= plt.figure()
# fig, ax = plt.subplots()
# fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.5))
ax = plt.axes(projection ='3d', adjustable='box')
# ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.17,0.23 ,0.7,0.7))
# ax = plt.axes((0.17,0.23 ,1.0,1.0))
# ax=plt.axes()
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
# c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
# Z = Z-c
#
# print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75) ,zorder=5)
step = (-1)*Z.min()
# step = 3.0
levels = np.arange(Z.min(),Z.max()/2,step)
# evels = np.arange(-4, 25, 4)
# levels = np.arange(-3, 23, 4)
# levels = np.arange(Z.min(),Z.max()/12,step)
# levels = np.arange(Z.min(),Z.max(),step)
# levels = np.arange(0,Z.max()/2,200)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
if case == 'b':
levels = np.arange(-4, 25, 4)
if case == 'a':
levels = np.arange(-1, 25, 5) # if g_star = [0 1]
levels = np.arange(0, 24, 4) # if g_star = [-1 1]
if case == 'c':
levels = np.arange(0, 25, 4)
# CS = ax.contour(a1, a2, Z,levels, colors='k',linewidths=(0.75), extent=(-2, 2, -2, 2), zorder=5)
# CS = ax.contour(a1 , a2 , Z, colors='k', linewidths=(0.75), zorder=5)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
# ax.clabel(CS, inline=True, fontsize=4)
# ax.clabel(CS, inline=True, fontsize=4)
# 1- ParameterFAMILY CASE :
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ),(-12.5,-12.5),(-14,-14), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
if case == 'c':
manual_locations = [
(1, 1), (0.5, 0.5),(1.5,1.5),(1.75,1.75),(-0.2,0.2), (-0.5,-0.5),
(-1,-1),(-1.25,-1.25), (-1.5,-1.5)]
# ax.clabel(CS, inline=True, fontsize=9, colors='black', manual=manual_locations)
else :
ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# GAMMA = inf
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
#
#
# # GAMMA = 0
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15), (-15,7),
# (5, 5), (10, 10 ), (15,15), (17,17)]
# ax.clabel(CS, inline=True, fontsize=f_size, colors='black')
# ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
cmap=mpl.cm.viridis_r
# cmap=mpl.cm.bwr
cmap=mpl.cm.coolwarm
# cmap=mpl.cm.gnuplot
cmap=mpl.cm.magma_r
# cmap=mpl.cm.inferno_r
# cmap=mpl.cm.plasma
# cmap=mpl.cm.plasma_r
# cmap=mpl.cm.cividis_r
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", [(0,"red"), (.1,"violet"), (.5, "blue"), (1.0, "green")])
# make a colormap that has land and ocean clearly delineated and of the
# same length (256 + 256)
#
# colors_undersea = plt.cm.terrain(np.linspace(0, 0.17, 256))
# colors_land = plt.cm.terrain(np.linspace(0.25, 1, 256))
# all_colors = np.vstack((colors_undersea, colors_land))
# # cmap = mcolors.LinearSegmentedColormap.from_list(
# # 'terrain_map', all_colors)
# cmap = px.colors.sequential.agsunset
# cmap = plotly.colors.PLOTLY_SCALES["Viridis"]
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=(Z.max()+Z.min())/2, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-500, vcenter=0, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0. ,vmax=10)
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0., vmax=Z.max())
# divnorm=mcolors.LogNorm(vmin=Z.min(), vmax=Z.max()) #Test LogNorm
# cmap = cm.brg(divnorm(Z))
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.9)
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = mcolors.CenteredNorm(),
# cmap=cmap, alpha=0.6)
# COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=f_size)
# fig.colorbar(I)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.2
epsilon = 0.005
epsilon = 0.01
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
fillcolor = 'white'
# ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([0+epsilon, x.max()-epsilon], y.min()+epsilon, 0-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min()+epsilon, 0-epsilon], 0+epsilon, y.max()-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
if case == 'c':
print('draw Line')
# line = draw_1ParameterLine(q1,q2,q12,q3)
else:
# PLOT MINIMIZER g*:
ax.scatter(g_star[0],g_star[1], s=20, zorder=5)
ax.text(g_star[0]+0.1,g_star[1]-0.1, r"$g_*$", color='royalblue', size=15, zorder = 5)
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
if case == 'c':
# draw minimizers
print('np.where(Z == Z.min())',np.where(np.round(Z,3) == np.round(Z.min(),3)))
# tmp_x = a1[np.where(np.round(Z,6) == np.round(Z.min(),6))]
# tmp_y = a2[np.where(np.round(Z,6) == np.round(Z.min(),6))]
# # ax.scatter(tmp_x,tmp_y,color='red', zorder=5, s=1)
# # ax.plot(tmp_x,tmp_y,color='red', zorder=5)
# ax.plot(tmp_x,tmp_y,color='royalblue', zorder=5)
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5, zorder=4)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5, zorder=4)
ax.set_xlabel(r"$a_1$", fontsize=f_size ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=f_size ,labelpad=0)
# ax.set_ylabel(r"energy")
ax.tick_params(axis='both', which='major', labelsize=f_size)
ax.tick_params(axis='both', which='minor', labelsize=f_size)
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# plt.subplots_adjust(left = 0.25 )
# ax.legend(loc='upper right')
# fig.subplots_adjust(left=.18, bottom=.12, right=.90, top=.97)
# fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.33))
Outputname = 'Energy_ContourG+_case'+ str(case) + '.pdf'
# fig.savefig(Outputname)
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# from ClassifyMin import *
from ClassifyMin_New import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
import matplotlib.ticker as ticker
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from chart_studio import plotly
import plotly.graph_objs as go
import plotly.express as px
import plotly.colors
# from matplotlib import rc
# rc('text', usetex=True) # Use LaTeX font
#
# import seaborn as sns
# sns.set(color_codes=True)
def show(fig):
import io
import plotly.io as pio
from PIL import Image
buf = io.BytesIO()
pio.write_image(fig, buf)
img = Image.open(buf)
img.show()
# set the colormap and centre the colorbar
class MidpointNormalize(mcolors.Normalize):
"""
Normalise the colorbar so that diverging bars work there way either side from a prescribed midpoint value)
e.g. im=ax1.imshow(array, norm=MidpointNormalize(midpoint=0.,vmin=-100, vmax=100))
"""
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
mcolors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
# I'm ignoring masked values and all kinds of edge cases to make a
# simple example...
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def set_size(width, fraction=1):
"""Set figure dimensions to avoid scaling in LaTeX.
Parameters
----------
width: float
Document textwidth or columnwidth in pts
fraction: float, optional
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure (in pts)
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
# https://disq.us/p/2940ij3
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
def format_func(value, tick_number):
# find number of multiples of pi/2
# N = int(np.round(2 * value / np.pi))
# if N == 0:
# return "0"
# elif N == 1:
# return r"$\pi/2$"
# elif N == -1:
# return r"$-\pi/2$"
# elif N == 2:
# return r"$\pi$"
# elif N % 2 > 0:
# return r"${0}\pi/2$".format(N)
# else:
# return r"${0}\pi$".format(N // 2)
##find number of multiples of pi/2
N = int(np.round(4 * value / np.pi))
if N == 0:
return "0"
elif N == 1:
return r"$\pi/4$"
elif N == -1:
return r"$-\pi/4$"
elif N == 2:
return r"$\pi/2$"
elif N == -2:
return r"$-\pi/2$"
elif N % 2 > 0:
return r"${0}\pi/2$".format(N)
else:
return r"${0}\pi$".format(N // 2)
def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]
def find_nearestIdx(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return idx
def check_case(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
print('g_star=', g_star)
return g_star
def get_gstar(q1,q2,q12,q3,b1,b2):
# a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
print('det(H)=', np.linalg.det(H))
# check if g* is in G^*_R^2
tmp = A.dot(b)
## compute inverse of H :
inv_H = np.linalg.inv(H)
g_star = 2*inv_H.dot(tmp)
# print('g_star=', g_star)
return g_star
def determine_b(q1,q2,q12,q3,g_star):
##
# Input: g_star
# Output : b such that g_star is minimizer, i.e A*b = (1/2)*H*g_star
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
rhs = (1/2)*H.dot(g_star)
print('rhs:', rhs)
b = np.linalg.lstsq(A, rhs)[0]
print('b',b)
b1=b[0]
b2=b[1]
return b
## ---------------
def get_minimizer(q1,q2,q3,b1,b2):
# In the case if q12 == 0:
quotient = (q1*q2-q3**2)
g_star = np.array([(q1*q2*b1-q3*q2*b2)/quotient, (q1*q2*b2-q3*q1*b1)/quotient])
print('g_star=', g_star)
return g_star
def energy(a1,a2,q1,q2,q12,q3,b1,b2):
a = np.array([a1,a2])
b = np.array([b1,b2])
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
tmp = H.dot(a)
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
tmp2 = A.dot(b)
# print('tmp2',tmp2)
tmp2 = 2*a.dot(tmp2)
# print('tmp2',tmp2)
energy = tmp - tmp2
# print('energy',energy)
# energy_axial1.append(energy_1)
return energy
# def energy(a1,a2,q1,q2,q12,q3,b1,b2):
#
#
# b = np.array([b1,b2])
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a',a)
# print('tmp',tmp)
#
# tmp = (1/2)*a.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a.dot(tmp2)
#
# print('tmp2',tmp2)
# energy = tmp - tmp2
# print('energy',energy)
#
#
# # energy_axial1.append(energy_1)
#
# return energy
#
def draw_1ParameterLine(q1,q2,q12,q3):
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
# print('abar:',np.shape(abar))
# print('np.transpose(abar):',np.shape(np.transpose(abar)))
sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# sstar = (1/(q1+q2))*abar.dot(tmp)
print('sstar', sstar)
abarperp= np.array([abar[1],-abar[0]])
print('abarperp:',abarperp)
N=500;
scale_domain = 5
translate_startpoint = -1.8
scale_domain = 4.65
translate_startpoint = -1.85
# --- FUll LINE:
scale_domain = 4.5
translate_startpoint = -1.4
T_line = np.linspace(-sstar*(q12+2*q3)/(2*q2)*scale_domain + translate_startpoint, sstar*(2*q2)/(q12+2*q3)*scale_domain , num=N)
line_values = []
for t in T_line :
print('sstar*abar+t*abarperp', sstar*abar+t*abarperp)
line_values.append(sstar*abar+t*abarperp)
# ------
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
# T = np.linspace(-sstar*(q12+2*q3)/(2*q2)*scale_domain + translate_startpoint, sstar*(2*q2)/(q12+2*q3)*scale_domain , num=N)
# T = np.linspace(-2,2, num=N)
# print('T:', T)
print('T.min():', T.min())
print('T.max():', T.max())
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
abar_tmp = abar
for t in T :
abar_current = sstar*abar+t*abarperp;
abar_current[abar_current < 1e-10] = 0 # Project to x-y-axis!!
current_energy = energy(abar_current[0],abar_current[1],q1,q2,q12,q3,b1,b2)
print('energy along line:', current_energy )
G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
G_container.append(G)
abar_container.append(abar_current)
e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
kappas.append(kappa)
alphas.append(alpha)
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('G_container', G_container)
G = np.array(G_container)
abar = np.array(abar_container)
# print('G', G)
# print('abar', abar)
# print('abar.shape',abar.shape)
line = ax.plot(abar[:,0],abar[:,1], linewidth=2, color='royalblue', linestyle='-', zorder=4)
# Plot 1-Parameter Line
line_values= np.array(line_values)
ax.plot(line_values[:,0],line_values[:,1],'k--', linewidth=1,color='royalblue',alpha=0.8,zorder=4)
return line
################################################################################################################
################################################################################################################
################################################################################################################
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
print('---- Input parameters: -----')
# q1=1;
# q2=2;
# q12=1/2;
# q3=((4*q1*q2)**0.5-q12)/2;
# # H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
# abar = np.array([q12+2*q3, 2*q2])
# abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
#
# print('abar:',abar)
#
# b = np.linalg.lstsq(A, abar)[0]
# print('b',b)
#
#
# # print('abar:',np.shape(abar))
# # print('np.transpose(abar):',np.shape(np.transpose(abar)))
# sstar = (1/(q1+q2))*abar.dot(A.dot(b))
# # sstar = (1/(q1+q2))*abar.dot(tmp)
# print('sstar', sstar)
# abarperp= np.array([abar[1],-abar[0]])
# print('abarperp:',abarperp)
# -------------------------- Input Parameters --------------------
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = 5.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#
# mu1 = 1.0
# rho1 = 1.0
# alpha = -0.75
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/2
# # theta= 0.1
# beta = 5.0
#Figure3:
# mu1 = 1.0
# rho1 = 1.0
# alpha = 2.0
# theta = 1.0/8
# # theta= 0.1
# beta = 2.0
# alpha= -5
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
# gamma = '0'
# # gamma = 'infinity'
#
#
# lambda1 = 0.0
print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# # print('alpha: ', alpha)
# print('beta: ', beta)
# # print('theta: ', theta)
# print('gamma:', gamma)
#
# print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
print('----------------------------')
# ----------------------------------------------------------------
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta)
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta)
# q12 = 0.0
# q3 = GetMuGamma(beta, theta,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, alpha, theta )
# b2 = prestrain_b2(rho1,beta, alpha, theta )
#
case = 'a'
# case = 'b'
# case = 'c'
if case == 'a':
print('---- CASE (a) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([0,1])
g_star = np.array([-1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'b':
print('---- CASE (b) ----')
q1 = 1
q2 = 2
q12 = 0
q3 = 1
g_star = np.array([1,1])
# ToDO
b = determine_b(q1,q2,q12,q3, g_star)
b1 = b[0]
b2 = b[1]
if case == 'c':
print('---- CASE (c) ----')
## ---- 1-ParameterFamilyCase:
q1=1;
q2=2;
q12=1/2;
q3=((4*q1*q2)**0.5-q12)/2;
# H=[2*q1,q12+2*q3;q12+2*q3,2*q2];
H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
abar = np.array([q12+2*q3, 2*q2])
abar = (1.0/math.sqrt((q12+2*q3)**2+(2*q2)**2))*abar
print('abar:',abar)
b = np.linalg.lstsq(A, abar)[0]
print('b',b)
b1=b[0]
b2=b[1]
## ---------------
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
## --- CHECK CASE ---
if case == 'a':
# Check Minimizers:
vec1 = np.array([(2*q1*b1+q12*b2)/(2*q1), 0])
vec2 = np.array([0, (2*q12*b1+q2*b2)/(2*q2)])
print('vec1:',vec1)
print('vec2:',vec2)
energy_1 = energy(vec1[0],vec1[1],q1,q2,q12,q3,b1,b2)
energy_2 = energy(vec2[0],vec2[1],q1,q2,q12,q3,b1,b2)
print('energy_1:',energy_1)
print('energy_2:',energy_2)
if energy_1 >= energy_2:
minvec = vec2
else:
minvec = vec1
print('minvec:', minvec)
check_case(q1,q2,q12,q3,b1,b2)
g_star = get_gstar(q1,q2,q12,q3,b1,b2)
print('g_star:',g_star)
# TEST
print('special case g_star:')
get_minimizer(q1,q2,q3,b1,b2)
## -------------------------------------
num_Points = 400
# num_Points = 600
# num_Points = 200
# num_Points = 100
# num_Points = 20
# Creating dataset
x = np.linspace(-5,5,num_Points)
y = np.linspace(-5,5,num_Points)
x = np.linspace(-20,20,num_Points)
y = np.linspace(-20,20,num_Points)
x = np.linspace(-2,2,num_Points)
y = np.linspace(-2,2,num_Points)
# x = np.linspace(-10,10,num_Points)
# y = np.linspace(-10,10,num_Points)
# x = np.linspace(-60,60,num_Points)
# y = np.linspace(-60,60,num_Points)
#
#
# x = np.linspace(-40,40,num_Points)
# y = np.linspace(-40,40,num_Points)
a1, a2 = np.meshgrid(x,y)
# geyser = sns.load_dataset("geyser")
# print('type of geyser:', type(geyser))
# print('geyser:',geyser)
# ContourRange=20
ContourRange=2
# x_in = np.linspace(-ContourRange,ContourRange,num_Points)
# y_in = np.linspace(-ContourRange,ContourRange,num_Points)
# a1_in, a2_in = np.meshgrid(x_in,y_in)
print('a1:', a1)
print('a2:',a2 )
print('a1.shape', a1.shape)
#-- FILTER OUT VALUES for G+ :
# tmp1 = a1[np.where(a1*a2 >= 0)]
# tmp2 = a2[np.where(a1*a2 >= 0)]
#
# np.take(a, np.where(a>100)[0], axis=0)
# tmp1 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = np.take(a1, np.where(a1*a2 >= 0)[0], axis=0)
# tmp2 = a2[np.where(a1*a2 >= 0)]
tmp1 = a1[a1*a2 >= 0]
tmp2 = a2[a1*a2 >= 0]
tmp1 = tmp1.reshape(-1,5)
tmp2 = tmp2.reshape(-1,5)
# tmp1_pos = a1[np.where(a1*a2 >= 0) ]
# tmp2_pos = a2[np.where(a1*a2 >= 0) ]
# tmp1_pos = tmp1_pos[np.where(tmp1_pos >= 0)]
# tmp2_pos = tmp2_pos[np.where(tmp2_pos >= 0)]
#
# tmp1_neg = a1[a1*a2 >= 0 ]
# tmp2_neg = a2[a1*a2 >= 0 ]
# tmp1_neg = tmp1_neg[tmp1_neg < 0]
# tmp2_neg = tmp2_neg[tmp2_neg < 0]
# a1 = tmp1
# a2 = tmp2
#
# a1 = a1.reshape(-1,5)
# a2 = a2.reshape(-1,5)
#
# tmp1_pos = tmp1_pos.reshape(-1,5)
# tmp2_pos = tmp2_pos.reshape(-1,5)
# tmp1_neg = tmp1_neg.reshape(-1,5)
# tmp2_neg = tmp2_neg.reshape(-1,5)
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
energyVec = np.vectorize(energy)
# Z = energyVec(np.array([a1,a2]),q1,q2,q12,q3,b1,b2)
Z = energyVec(a1,a2,q1,q2,q12,q3,b1,b2)
# Z_in = energyVec(a1_in,a2_in,q1,q2,q12,q3,b1,b2)
print('Z:', Z)
print('any', np.any(Z<0))
# negZ_a1 = a1[np.where(Z<0)]
# negZ_a2 = a2[np.where(Z<0)]
# negativeValues = Z[np.where(Z<0)]
# print('negativeValues:',negativeValues)
#
# print('negZ_a1',negZ_a1)
# print('negZ_a2',negZ_a2)
#
#
# negZ_a1 = negZ_a1.reshape(-1,5)
# negZ_a2 = negZ_a2.reshape(-1,5)
# negativeValues = negativeValues.reshape(-1,5)
#
# Z_pos = energyVec(tmp1_pos,tmp2_pos,q1,q2,q12,q3,b1,b2)
# Z_neg = energyVec(tmp1_neg,tmp2_neg,q1,q2,q12,q3,b1,b2)
# print('Test energy:' , energy(np.array([1,1]),q1,q2,q12,q3,b1,b2))
# print('Z_pos.shape', Z_pos.shape)
## -- PLOT :
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
#
# label_size = 8
# mpl.rcParams['xtick.labelsize'] = label_size
# mpl.rcParams['ytick.labelsize'] = label_size
#
# label_size = 9
# mpl.rcParams['xtick.labelsize'] = label_size
# mpl.rcParams['ytick.labelsize'] = label_size
label_size = 10
#--- change plot style: SEABORN
# plt.style.use("seaborn-paper")
# plt.style.use("seaborn-darkgrid")
# plt.style.use("seaborn-whitegrid")
# plt.style.use("seaborn")
# plt.style.use("seaborn-paper")
# plt.style.use('ggplot')
# plt.rcParams["font.family"] = "Avenir"
# plt.rcParams["font.size"] = 16
# plt.style.use("seaborn-darkgrid")
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "10"
# mpl.rcParams['xtick.labelsize'] = 16mpl.rcParams['xtick.major.size'] = 2.5
# mpl.rcParams['xtick.bottom'] = True
# mpl.rcParams['ticks'] = True
mpl.rcParams['xtick.bottom'] = True
mpl.rcParams['xtick.major.size'] = 3
mpl.rcParams['xtick.minor.size'] = 1.5
mpl.rcParams['xtick.major.width'] = 0.75
mpl.rcParams['ytick.left'] = True
mpl.rcParams['ytick.major.size'] = 3
mpl.rcParams['ytick.minor.size'] = 1.5
mpl.rcParams['ytick.major.width'] = 0.75
mpl.rcParams.update({'font.size': 10})
mpl.rcParams['axes.labelpad'] = 3.0
#--- Adjust gobal matplotlib variables
# mpl.rcParams['pdf.fonttype'] = 42
# mpl.rcParams['ps.fonttype'] = 42
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "10"
width = 6.28 *0.5
# width = 6.28 *0.33
# width = 6.28
height = width #/ 1.618
# width = 452.9579/2
# size= set_size(width, fraction=0.5)
# print('set_size(width, fraction=0.5)', set_size(width, fraction=1))
# print('size[0]',size[0])
f_size = 10
# fig= plt.figure()
fig, ax = plt.subplots()
# fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.5))
# ax = plt.axes(projection ='3d', adjustable='box')
# ax = plt.axes((0.17,0.21 ,0.75,0.75))
# ax = plt.axes((0.17,0.23 ,0.7,0.7))
# ax = plt.axes((0.17,0.23 ,1.0,1.0))
# ax=plt.axes()
# ax = plt.axes((0.15,0.18,0.8,0.8))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# ax.xaxis.set_major_locator(MultipleLocator(0.1))
# ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
# colorfunction=(B*kappa)
# print('colofunction',colorfunction)
#translate Data
# Z = Z - (Z.max()-Z.min())/2
# Z = Z - 50
# Z = Z - 500
#
# Z = Z.T
# Substract constant:
# c = (b1**2)*q1+b1*b2*q12+(b2**2)*q2
# Z = Z-c
#
# print('Value of c:', c)
print('Z.min()', Z.min())
print('Z.max()', Z.max())
norm=mcolors.Normalize(Z.min(),Z.max())
# facecolors=cm.brg(norm)
print('norm:', norm)
print('type of norm', type(norm))
print('norm(0):', norm(0))
print('norm(Z):', norm(Z))
# ax.plot(theta_rho, theta_values, 'royalblue', zorder=3, )
# ax.scatter(a1,a2, s=0.5)
# ax.scatter(tmp1_pos,tmp2_pos, s=0.5)
# ax.scatter(tmp1_neg,tmp2_neg, s=0.5)
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=100 )
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, levels=20 )
# sns.kdeplot(np.array([a1, a2, Z]))
# sns.kdeplot(tmp1_pos,tmp2_pos,Z_pos)
# levels = [-5.0, -4, -3, 0.0, 1.5, 2.5, 3.5]
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, corner_mask=True,levels=levels)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot(norm(Z)), corner_mask=True)
# CS = ax.contour(a1, a2, Z, cm.brg(norm(Z)), levels=20)
# CS = ax.contour(a1, a2, Z, cmap=plt.cm.gnuplot, levels=20)
# CS = ax.contour(a1, a2, Z, colors='k', levels=14, linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z, colors='k', levels=18, linewidths=(0.5,))
# ax.contour(negZ_a1, negZ_a2, negativeValues, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75) ,zorder=5)
step = (-1)*Z.min()
# step = 3.0
levels = np.arange(Z.min(),Z.max()/2,step)
# evels = np.arange(-4, 25, 4)
# levels = np.arange(-3, 23, 4)
# levels = np.arange(Z.min(),Z.max()/12,step)
# levels = np.arange(Z.min(),Z.max(),step)
# levels = np.arange(0,Z.max()/2,200)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.75), levels=levels ,zorder=5)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
# CS = ax.contour(a1, a2, Z,5, colors='k', linewidths=(0.75) ,zorder=5, vmin=Z.min(), vmax=1)
if case == 'b':
levels = np.arange(-4, 25, 4)
if case == 'a':
levels = np.arange(-1, 25, 5) # if g_star = [0 1]
levels = np.arange(0, 24, 4) # if g_star = [-1 1]
if case == 'c':
levels = np.arange(0, 25, 4)
CS = ax.contour(a1, a2, Z,levels, colors='k',linewidths=(0.75), extent=(-2, 2, -2, 2), zorder=5)
# CS = ax.contour(a1 , a2 , Z, colors='k', linewidths=(0.75), zorder=5)
# CS = ax.contour(a1_in, a2_in, Z_in, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(1) , vmin= Z.min()+0.04, zorder=5)
# df = pd.DataFrame(data=Z_in, columns=a1_in, index=a2_in)
# df2 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
# columns=['a', 'b', 'c'])
# sns.kdeplot(data=df2, x="waiting", y="duration")
# sns.kdeplot(data=df2)
# CS = ax.contour(a1, a2, Z, colors='k', linewidths=(0.5,))
# CS = ax.contour(a1, a2, Z,10, cmap=plt.cm.gnuplot, extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k', extend='both', levels=50)
# CS = ax.contourf(a1, a2, Z,10, colors='k')
#
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, levels=10 )
# # CS = ax.contour(tmp1_pos,tmp2_pos, Z_pos,10, cmap=plt.cm.gnuplot, corner_mask=True)
#
# CS = ax.contour(a1, a2, Z,10, colors = 'k')
# ax.clabel(CS, inline=True, fontsize=4)
# ax.clabel(CS, inline=True, fontsize=4)
# 1- ParameterFAMILY CASE :
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ),(-12.5,-12.5),(-14,-14), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
if case == 'c':
manual_locations = [
(1, 1), (0.5, 0.5),(1.5,1.5),(1.75,1.75),(-0.2,0.2), (-0.5,-0.5),
(-1,-1),(-1.25,-1.25), (-1.5,-1.5)]
ax.clabel(CS, inline=True, fontsize=9, colors='black', manual=manual_locations)
if case == 'b':
manual_locations = [
(0.5, 0.5),(-0.2,0.2),(-0.2,-0.2),(-0.5,-0.5), (-0.75,-0.75),
(-1,-1),(-1.25,-1.25), (-1.5,-1.5)]
ax.clabel(CS, inline=True, fontsize=9, colors='black', manual=manual_locations)
if case == 'a':
manual_locations = [
(1.8,1.8),(1.5,1.5) , (1, 1.5),(-1,0.25),(-0.75,-0.75),
(-1,-1),(-1.25,-1.25), (-1.5,-1.5)]
ax.clabel(CS, inline=True, fontsize=9, colors='black', manual=manual_locations)
# else :
# ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# GAMMA = inf
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15),
# (5, 5), (10, 10 ),(12.5,12.5), (15,15), (17,17)]
#
#
# # GAMMA = 0
# manual_locations = [
# (1, 1), (-5, -5), (-10, -10 ), (-15,-15), (-15,7),
# (5, 5), (10, 10 ), (15,15), (17,17)]
# ax.clabel(CS, inline=True, fontsize=f_size, colors='black')
# ax.clabel(CS, inline=True, fontsize=9, colors='black', zorder=5)
# cmap = cm.brg(norm(Z))
#
# C_map = cm.inferno(norm(Z))
# ax.imshow(Z, cmap=C_map, extent=[-20, 20, -20, 20], origin='lower', alpha=0.5)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20], origin='lower',
# cmap='bwr', alpha=0.8)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', vmin=Z.min(), vmax=Z.max(),
# cmap='bwr', alpha=0.6)
# ax.imshow(norm(Z), extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
cmap=mpl.cm.RdBu_r
cmap=mpl.cm.viridis_r
# cmap=mpl.cm.bwr
cmap=mpl.cm.coolwarm
# cmap=mpl.cm.gnuplot
cmap=mpl.cm.magma_r
# cmap=mpl.cm.inferno_r
# cmap=mpl.cm.plasma
# cmap=mpl.cm.plasma_r
# cmap=mpl.cm.cividis_r
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", [(0,"red"), (.1,"violet"), (.5, "blue"), (1.0, "green")])
# make a colormap that has land and ocean clearly delineated and of the
# same length (256 + 256)
#
# colors_undersea = plt.cm.terrain(np.linspace(0, 0.17, 256))
# colors_land = plt.cm.terrain(np.linspace(0.25, 1, 256))
# all_colors = np.vstack((colors_undersea, colors_land))
# # cmap = mcolors.LinearSegmentedColormap.from_list(
# # 'terrain_map', all_colors)
# cmap = px.colors.sequential.agsunset
# cmap = plotly.colors.PLOTLY_SCALES["Viridis"]
# cmap = cm.brg(Z)
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=(Z.max()+Z.min())/2, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-500, vcenter=0, vmax=Z.max())
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0. ,vmax=10)
# divnorm=mcolors.TwoSlopeNorm(vmin=-10, vcenter=0., vmax=Z.max())
# divnorm=mcolors.LogNorm(vmin=Z.min(), vmax=Z.max()) #Test LogNorm
# cmap = cm.brg(divnorm(Z))
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower', norm = norm,
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap='coolwarm', alpha=0.6)
# ax.imshow(Z, extent=[-20, 20, -20, 20],origin='lower',
# cmap=cmap, alpha=0.6)
# divnorm=mcolors.TwoSlopeNorm(vmin=Z.min(), vcenter=0., vmax=Z.max())
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
cmap=cmap, alpha=0.9)
# plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = divnorm,
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower',
# cmap=cmap, alpha=0.6)
# I = plt.imshow(Z, extent=[x.min(), x.max(), y.min(), y.max()],origin='lower', norm = mcolors.CenteredNorm(),
# cmap=cmap, alpha=0.6)
# COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=f_size)
# fig.colorbar(I)
##----- ADD RECTANGLE TO COVER QUADRANT :
epsilon = 0.4
epsilon = 0.2
epsilon = 0.005
epsilon = 0.01
# ax.axvspan(0, x.max(), y.min(), 0, alpha=1, color='yellow', zorder=5)#yellow
# ax.fill_between([0, x.max()], y.min(), 0, alpha=0.3, color='yellow', zorder=5)#yellow
# ax.fill_between([x.min(), 0], 0, y.max(), alpha=0.3, color='yellow', zorder=5)#yellow
fillcolor = 'white'
# ax.fill_between([0+epsilon, x.max()], y.min(), 0-epsilon, alpha=0.7, color=fillcolor, zorder=4)#yellow
# ax.fill_between([x.min(), 0-epsilon], 0+epsilon, y.max(), alpha=0.7, color=fillcolor, zorder=4)#yellow
ax.fill_between([0+epsilon, x.max()-epsilon], y.min()+epsilon, 0-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
ax.fill_between([x.min()+epsilon, 0-epsilon], 0+epsilon, y.max()-epsilon, alpha=1.0, color=fillcolor, zorder=4)#yellow
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot(theta_rho, energy_axial1, 'royalblue', zorder=3, label=r"axialMin1")
# ax.plot(theta_rho, energy_axial2, 'forestgreen', zorder=3, label=r"axialMin2")
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
if case == 'a':
# PLOT MINIMIZER g*:
# ax.scatter(g_star[0],g_star[1], s=20, zorder=5)
# ax.scatter(g_star[0],g_star[1], marker = 'x', s=20, zorder=5)
# ax.text(g_star[0]+0.1,g_star[1]-0.1, r"$g_*$", color='royalblue', size=15, zorder = 5)
ax.scatter(g_star[0],g_star[1], marker = 'x', s=40, color='darkslategray', zorder=4)
ax.text(g_star[0]+0.15,g_star[1]-0.15, r"$g_*$", color='darkslategray', size=13, alpha=1.0, zorder = 5)
if case == 'b':
# PLOT MINIMIZER g*:
ax.scatter(g_star[0],g_star[1], s=20, color='royalblue', zorder=5)
ax.scatter(g_star[0],g_star[1], marker = 'x', s=40, color='darkslategray', zorder=4)
ax.text(g_star[0]+0.15,g_star[1]-0.15, r"$g_*$", color='darkslategray', size=13, alpha=1.0, zorder = 5)
if case == 'c':
print('draw Line')
line = draw_1ParameterLine(q1,q2,q12,q3)
# lg = ax.legend(bbox_to_anchor=(0.0, 0.75), loc='upper left')
if case == 'c':
# draw MINIMAL VALUES
print('np.where(Z == Z.min())',np.where(np.round(Z,6) == np.round(Z.min(),6)))
tmp_x = a1[np.where(np.round(Z,6) == np.round(Z.min(),6))]
tmp_y = a2[np.where(np.round(Z,6) == np.round(Z.min(),6))]
# ax.scatter(tmp_x,tmp_y,color='red', zorder=5, s=1)
# ax.plot(tmp_x,tmp_y,color='forestgreen', zorder=5)
# print('np.where(Z == Z.min())',np.where(np.round(Z,8) == np.round(Z.min(),8)))
if case == 'a':
ax.scatter(minvec[0],minvec[1],color='royalblue',zorder=5, s=20)
### PLot x and y- Axes
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5, zorder=4)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5, zorder=4)
# ax.set_xlabel(r"$a_1$", fontsize=f_size ,labelpad=0)
# ax.set_ylabel(r"$a_2$", fontsize=f_size ,labelpad=0)
ax.set_xlabel(r"$a_1$", fontsize=f_size )
ax.set_ylabel(r"$a_2$", fontsize=f_size, rotation=0 )
# ax.set_ylabel(r"energy")
ax.tick_params(axis='both', which='major', labelsize=f_size)
ax.tick_params(axis='both', which='minor', labelsize=f_size)
# ax.set_xticks([-np.pi/2, -np.pi/4 ,0, np.pi/4, np.pi/2 ])
# labels = ['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$']
# ax.set_yticklabels(labels)
# plt.subplots_adjust(left = 0.25 )
# ax.legend(loc='upper right')
fig.subplots_adjust(left=.18, bottom=.12, right=.90, top=.97)
fig.set_size_inches(width, height)
# fig.set_size_inches(set_size(width, fraction=0.33))
Outputname = 'Energy_ContourG+_case'+ str(case) + '.pdf'
fig.savefig(Outputname)
plt.show()
#
#
#
# # Curve parametrised by \theta_rho = alpha in parameter space
# N=100;
# theta_rho = np.linspace(1, 3, num=N)
# print('theta_rho:', theta_rho)
#
#
# theta_values = []
#
#
# for t in theta_rho:
#
# s = (1.0/10.0)*t+0.1
# theta_values.append(s)
#
#
#
#
#
# theta_rho = np.array(theta_rho)
# theta_values = np.array(theta_values)
#
# betas_ = 2.0
#
# alphas, betas, thetas = np.meshgrid(theta_rho, betas_, theta_values, indexing='ij')
#
#
# harmonicMeanVec = np.vectorize(harmonicMean)
# arithmeticMeanVec = np.vectorize(arithmeticMean)
# prestrain_b1Vec = np.vectorize(prestrain_b1)
# prestrain_b2Vec = np.vectorize(prestrain_b2)
#
# GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
#
# q1_vec = harmonicMeanVec(mu1, betas, thetas)
# q2_vec = arithmeticMeanVec(mu1, betas, thetas)
#
# b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# special case: q12 == 0!! .. braucht eigentlich nur b1 & b2 ...
# print('type b1_values:', type(b1_values))
# print('size(q1)',q1.shape)
#
#
# energy_axial1 = []
# energy_axial2 = []
#
# # for b1 in b1_values:
# for i in range(len(theta_rho)):
# print('index i:', i)
#
# print('theta_rho[i]',theta_rho[i])
# print('theta_values[i]',theta_values[i])
#
# q1 = (1.0/6.0)*harmonicMean(mu1, beta, theta_values[i])
# q2 = (1.0/6.0)*arithmeticMean(mu1, beta, theta_values[i])
# q12 = 0.0
# q3 = GetMuGamma(beta, theta_values[i],gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# b1 = prestrain_b1(rho1,beta, theta_rho[i],theta_values[i] )
# b2 = prestrain_b2(rho1,beta, theta_rho[i],theta_values[i] )
#
#
# # q2_vec = arithmeticMean(mu1, betas, thetas)
# #
# # b1_vec = prestrain_b1Vec(rho1, betas, alphas, thetas)
# # b2_vec = prestrain_b2Vec(rho1, betas, alphas, thetas)
# print('q1[i]',q1)
# print('q2[i]',q2)
# print('q3[i]',q3)
# print('b1[i]',b1)
# print('b2[i]',b2)
# # print('q1[i]',q1[0][i])
# # print('q2[i]',q2[i])
# # print('b1[i]',b1[i])
# # print('b2[i]',b2[i])
# #compute axial energy #1 ...
#
# a_axial1 = np.array([b1,0])
# a_axial2 = np.array([0,b2])
# b = np.array([b1,b2])
#
# H = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# A = np.array([[q1,1/2*q12], [1/2*q12,q2] ])
#
#
# tmp = H.dot(a_axial1)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial1',a_axial1)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial1.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial1.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_1 = tmp - tmp2
# print('energy_1',energy_1)
#
#
# energy_axial1.append(energy_1)
#
#
# tmp = H.dot(a_axial2)
#
# print('H',H)
# print('A',A)
# print('b',b)
# print('a_axial2',a_axial2)
# print('tmp',tmp)
#
# tmp = (1/2)*a_axial2.dot(tmp)
# print('tmp',tmp)
#
# tmp2 = A.dot(b)
# print('tmp2',tmp2)
# tmp2 = 2*a_axial2.dot(tmp2)
#
# print('tmp2',tmp2)
# energy_2 = tmp - tmp2
# print('energy_2',energy_2)
#
#
# energy_axial2.append(energy_2)
#
#
#
#
#
# print('theta_values', theta_values)
#
#
#
#
#
#
#
# kappas = []
# alphas = []
# # G.append(float(s[0]))
#
#
#
#
# for t in T :
#
# abar_current = sstar*abar+t*abarperp;
# # print('abar_current', abar_current)
# abar_current[abar_current < 1e-10] = 0
# # print('abar_current', abar_current)
#
# # G = np.array([[2*q1, q12+2*q3], [q12+2*q3,2*q2] ])
# G = [abar_current[0], abar_current[1] , (2*abar_current[0]*abar_current[1])**0.5 ]
#
# e = [(abar_current[0]/(abar_current[0]+abar_current[1]))**0.5, (abar_current[1]/(abar_current[0]+abar_current[1]))**0.5]
# kappa = abar_current[0]+abar_current[1]
# alpha = math.atan2(e[1], e[0])
#
# print('angle current:', alpha)
#
# kappas.append(kappa)
# alphas.append(alpha)
#
#
#
# alphas = np.array(alphas)
# kappas = np.array(kappas)
#
#
# print('kappas:',kappas)
# print('alphas:',alphas)
# print('min alpha:', min(alphas))
# print('min kappa:', min(kappas))
#
# mpl.rcParams['text.usetex'] = True
# mpl.rcParams["font.family"] = "serif"
# mpl.rcParams["font.size"] = "9"
# width = 6.28 *0.5
# height = width / 1.618
# fig = plt.figure()
# # ax = plt.axes((0.15,0.21 ,0.75,0.75))
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# ax.tick_params(axis='x',which='major', direction='out',pad=5)
# ax.tick_params(axis='y',which='major', length=3, width=1, direction='out',pad=3)
# # ax.xaxis.set_major_locator(MultipleLocator(0.1))
# # ax.xaxis.set_minor_locator(MultipleLocator(0.05))
# # ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 8))
# # ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 16))
# ax.xaxis.set_major_locator(plt.MultipleLocator(np.pi / 2))
# ax.xaxis.set_minor_locator(plt.MultipleLocator(np.pi / 4))
# ax.xaxis.set_major_formatter(plt.FuncFormatter(format_func))
# ax.grid(True,which='major',axis='both',alpha=0.3)
#
#
#
#
# ax.plot(alphas, kappas, 'royalblue', zorder=3, )
# ax.plot(-1.0*alphas, kappas, 'red', zorder=3, )
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import time
# from ClassifyMin import *
from ClassifyMin_New import *
# from scipy.io import loadmat #not Needed anymore?
import codecs
import sys
def ReadEffectiveQuantities(QFilePath = os.path.dirname(os.getcwd()) + '/outputs/QMatrix.txt', BFilePath = os.path.dirname(os.getcwd())+ '/outputs/BMatrix.txt'):
# Read Output Matrices (effective quantities)
# From Cell-Problem output Files : ../outputs/Qmatrix.txt , ../outputs/Bmatrix.txt
# -- Read Matrix Qhom
X = []
# with codecs.open(path + '/outputs/QMatrix.txt', encoding='utf-8-sig') as f:
with codecs.open(QFilePath, encoding='utf-8-sig') as f:
for line in f:
s = line.split()
X.append([float(s[i]) for i in range(len(s))])
Q = np.array([[X[0][2], X[1][2], X[2][2]],
[X[3][2], X[4][2], X[5][2]],
[X[6][2], X[7][2], X[8][2]] ])
# -- Read Beff (as Vector)
X = []
# with codecs.open(path + '/outputs/BMatrix.txt', encoding='utf-8-sig') as f:
with codecs.open(BFilePath, encoding='utf-8-sig') as f:
for line in f:
s = line.split()
X.append([float(s[i]) for i in range(len(s))])
B = np.array([X[0][2], X[1][2], X[2][2]])
return Q, B
def SetParametersCellProblem(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset"):
with open(InputFilePath, 'r') as file:
filedata = file.read()
filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
filedata = re.sub('(?m)^lambda1=.*','lambda1='+str(lambda1),filedata)
f = open(InputFilePath,'w')
f.write(filedata)
f.close()
#TODO combine these...
def SetParametersComputeMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset"):
with open(InputFilePath, 'r') as file:
filedata = file.read()
filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
f = open(InputFilePath,'w')
f.write(filedata)
f.close()
def RunCellProblem(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset"):
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
SetParametersCellProblem(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath)
# --- Run Cell-Problem
# Optional: Check Time
# t = time.time()
subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
capture_output=True, text=True)
# print('elapsed time:', time.time() - t)
# --------------------------------------------------------------------------------------
def GetCellOutput(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
RunCellProblem(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath)
print('Read effective quantities...')
Q, B = ReadEffectiveQuantities()
# print('Q:', Q)
# print('B:', B)
return Q, B
# unabhängig von alpha...
def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
# ------------------------------------ get mu_gamma ------------------------------
# ---Scenario 1.1: extreme regimes
if gamma == '0':
# print('extreme regime: gamma = 0')
mu_gamma = (1.0/6.0)*arithmeticMean(mu1, beta, theta) # = q2
# print("mu_gamma:", mu_gamma)
elif gamma == 'infinity':
# print('extreme regime: gamma = infinity')
mu_gamma = (1.0/6.0)*harmonicMean(mu1, beta, theta) # = q1
# print("mu_gamma:", mu_gamma)
else:
# --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# print("Run computeMuGamma for Gamma = ", gamma)
SetParametersComputeMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# --- Run Cell-Problem
# Check Time
# t = time.time()
# subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
# capture_output=True, text=True)
# --- Run Cell-Problem_muGama -> faster
# subprocess.run(['./build-cmake/src/Cell-Problem_muGamma', './inputs/cellsolver.parset'],
# capture_output=True, text=True)
# --- Run Compute_muGamma (2D Problem much much faster)
subprocess.run(['./build-cmake/src/Compute_MuGamma', './inputs/computeMuGamma.parset'],
capture_output=True, text=True)
# print('elapsed time:', time.time() - t)
#Extract mu_gamma from Output-File TODO: GENERALIZED THIS FOR QUANTITIES OF INTEREST
with open(OutputFilePath, 'r') as file:
output = file.read()
tmp = re.search(r'(?m)^mu_gamma=.*',output).group() # Not necessary for Intention of Program t output Minimizer etc.....
s = re.findall(r"[-+]?\d*\.\d+|\d+", tmp)
mu_gamma = float(s[0])
# print("mu_gamma:", mu_gammaValue)
# --------------------------------------------------------------------------------------
return mu_gamma
def Compare_Classification(alpha,beta,theta,gamma,mu1,rho1,lambda1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset"):
# ---------------------------------------------------------------
# Comparison of the analytical Classification 'ClassifyMin'
# and the symbolic Minimizatio + Classification 'symMinimization'
# ----------------------------------------------------------------
comparison_successful = True
eps = 1e-8
# 1. Substitute Input-Parameters for the Cell-Problem
with open(InputFilePath, 'r') as file:
filedata = file.read()
filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
filedata = re.sub('(?m)^lambda1=.*','lambda1='+str(lambda1),filedata)
f = open(InputFilePath,'w')
f.write(filedata)
f.close()
# 2. --- Run Cell-Problem
print('Run Cell-Problem ...')
# Optional: Check Time
# t = time.time()
subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
capture_output=True, text=True)
# 3. --- Run Matlab symbolic minimization program: 'symMinimization'
eng = matlab.engine.start_matlab()
# s = eng.genpath(path + '/Matlab-Programs')
s = eng.genpath(os.path.dirname(os.getcwd()))
eng.addpath(s, nargout=0)
# print('current Matlab folder:', eng.pwd(nargout=1))
eng.cd('Matlab-Programs', nargout=0) #switch to Matlab-Programs folder
# print('current Matlab folder:', eng.pwd(nargout=1))
Inp = False
print('Run symbolic Minimization...')
G, angle, type, kappa = eng.symMinimization(Inp,Inp,Inp,Inp, nargout=4) #Name of program:symMinimization
# G, angle, type, kappa = eng.symMinimization(Inp,Inp,Inp,Inp,path + "/outputs", nargout=4) #Optional: add Path
G = np.asarray(G) #cast Matlab Outout to numpy array
# --- print Output ---
print('Minimizer G:')
print(G)
print('angle:', angle)
print('type:', type )
print('curvature:', kappa)
# 4. --- Read the effective quantities (output values of the Cell-Problem)
# Read Output Matrices (effective quantities)
print('Read effective quantities...')
Q, B = ReadEffectiveQuantities()
print('Q:', Q)
print('B:', B)
q1 = Q[0][0]
q2 = Q[1][1]
q3 = Q[2][2]
q12 = Q[0][1]
b1 = B[0]
b2 = B[1]
b3 = B[2]
print("q1:", q1)
print("q2:", q2)
print("q3:", q3)
print("q12:", q12)
print("b1:", b1)
print("b2:", b2)
print("b3:", b3)
# --- Check Assumptions:
# Assumption of Classification-Lemma1.6: [b3 == 0] & [Q orthotropic]
# Check if b3 is close to zero
assert (b3 < eps), "ClassifyMin only defined for b3 == 0 !"
# Check if Q is orthotropic i.e. q13 = q31 = q23 = q32 == 0
assert(Q[2][0] < eps and Q[0][2] < eps and Q[1][2] < eps and Q[2][1] < eps), "Q is not orthotropic !"
# 5. --- Get output from the analytical Classification 'ClassifyMin'
G_ana, angle_ana, type_ana, kappa_ana = classifyMin(q1, q2, q3, q12, b1, b2)
print('Minimizer G_ana:')
print(G_ana)
print('angle_ana:', angle_ana)
print('type_ana:', type_ana )
print('curvature_ana:', kappa_ana)
# 6. Compare
# print('DifferenceMatrix:', G_ana - G )
# print('MinimizerError (FrobeniusNorm):', np.linalg.norm(G_ana - G , 'fro') )
if np.linalg.norm(G_ana - G , 'fro') > eps :
comparison_successful = False
print('Difference between Minimizers is too large !')
if type != type_ana :
comparison_successful = False
print('Difference in type !')
if abs(angle-angle_ana) > eps :
comparison_successful = False
print('Difference in angle is too large!')
if abs(kappa-kappa_ana) > eps :
comparison_successful = False
print('Difference in curvature is too large!')
if comparison_successful:
print('Comparison successful')
else:
print('Comparison unsuccessful')
return comparison_successful
# ----------------------------------------------------------------------------------------------------------------------------
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# from ClassifyMin import *
from ClassifyMin_New import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
import time
from chart_studio import plotly
import plotly.graph_objs as go
import mayavi.mlab as mlab
from mayavi.api import OffScreenEngine
import scipy.signal
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import pandas as pd
import seaborn as sns
import matplotlib.colors as mcolors
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
# mlab.options.offscreen = True
# print(sys.executable)
# --------------------------------------------------------------------
# START :
# INPUT (Parameters): alpha, beta, theta, gamma, mu1, rho1
#
# -Option 1 : (Case lambda = 0 => q12 = 0)
# compute q1,q2,b1,b2 from Formula
# Option 1.1 :
# set mu_gamma = 'q1' or 'q2' (extreme regimes: gamma \in {0,\infty})
# Option 1.2 :
# compute mu_gamma with 'Compute_MuGamma' (2D problem much faster then Cell-Problem)
# -Option 2 :
# compute Q_hom & B_eff by running 'Cell-Problem'
#
# -> CLASSIFY ...
#
# OUTPUT: Minimizer G, angle , type, curvature
# -----------------------------------------------------------------------
#
#
# def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
# OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
# # ------------------------------------ get mu_gamma ------------------------------
# # ---Scenario 1.1: extreme regimes
# if gamma == '0':
# print('extreme regime: gamma = 0')
# mu_gamma = (1.0/6.0)*arithmeticMean(mu1, beta, theta) # = q2
# print("mu_gamma:", mu_gamma)
# elif gamma == 'infinity':
# print('extreme regime: gamma = infinity')
# mu_gamma = (1.0/6.0)*harmonicMean(mu1, beta, theta) # = q1
# print("mu_gamma:", mu_gamma)
# else:
# # --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# # print("Run computeMuGamma for Gamma = ", gamma)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# # --- Run Cell-Problem
#
# # Check Time
# # t = time.time()
# # subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Cell-Problem_muGama -> faster
# # subprocess.run(['./build-cmake/src/Cell-Problem_muGamma', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Compute_muGamma (2D Problem much much faster)
#
# subprocess.run(['./build-cmake/src/Compute_MuGamma', './inputs/computeMuGamma.parset'],
# capture_output=True, text=True)
# # print('elapsed time:', time.time() - t)
#
# #Extract mu_gamma from Output-File TODO: GENERALIZED THIS FOR QUANTITIES OF INTEREST
# with open(OutputFilePath, 'r') as file:
# output = file.read()
# tmp = re.search(r'(?m)^mu_gamma=.*',output).group() # Not necessary for Intention of Program t output Minimizer etc.....
# s = re.findall(r"[-+]?\d*\.\d+|\d+", tmp)
# mu_gamma = float(s[0])
# # print("mu_gamma:", mu_gammaValue)
# # --------------------------------------------------------------------------------------
# return mu_gamma
#
# ----------- SETUP PATHS
# InputFile = "/inputs/cellsolver.parset"
# OutputFile = "/outputs/output.txt"
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
# -------------------------- Input Parameters --------------------
# mu1 = 10.0 # TODO : here must be the same values as in the Parset for computeMuGamma
mu1 = 1.0
rho1 = 1.0
alpha = 2.0
beta = 2.0
# beta = 5.0
theta = 1.0/4.0
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
# gamma = 'infinity'
# gamma = 0.5
# gamma = 0.25
# gamma = 1.0
# gamma = 5.0
#added
# lambda1 = 10.0
lambda1 = 0.0
#Test:
# rho1 = -1.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
print('alpha: ', alpha)
print('beta: ', beta)
print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
#
# gamma_min = 0.5
# gamma_max = 1.0
#
# # gamma_min = 1
# # gamma_max = 1
# Gamma_Values = np.linspace(gamma_min, gamma_max, num=3)
# # #
# # # Gamma_Values = np.linspace(gamma_min, gamma_max, num=13) # TODO variable Input Parameters...alpha,beta...
# print('(Input) Gamma_Values:', Gamma_Values)
print('type of gamma:', type(gamma))
# # #
# Gamma_Values = ['0', 'infinity']
# Gamma_Values = ['infinity']
Gamma_Values = ['0']
# Gamma_Values = [ 'infinity','0']
print('(Input) Gamma_Values:', Gamma_Values)
for gamma in Gamma_Values:
print('Run for gamma = ', gamma)
print('type of gamma:', type(gamma))
# muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1,InputFilePath)
# # muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1)
# print('Test MuGamma:', muGamma)
# ------- Options --------
# print_Cases = True
# print_Output = True
#TODO
# generalCase = True #Read Output from Cell-Problem instead of using Lemma1.4 (special case)
generalCase = False
make_3D_plot = True
make_3D_PhaseDiagram = True
make_2D_plot = False
make_2D_PhaseDiagram = False
make_3D_plot = False
# make_3D_PhaseDiagram = False
# make_2D_plot = True
# make_2D_PhaseDiagram = True
#
# --- Define effective quantities: q1, q2 , q3 = mu_gamma, q12 ---
# q1 = harmonicMean(mu1, beta, theta)
# q2 = arithmeticMean(mu1, beta, theta)
# --- Set q12
# q12 = 0.0 # (analytical example) # TEST / TODO read from Cell-Output
# b1 = prestrain_b1(rho1, beta, alpha, theta)
# b2 = prestrain_b2(rho1, beta, alpha, theta)
#
# print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# print("machine epsilon", sys.float_info.epsilon)
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# ---------------------- MAKE PLOT / Write to VTK------------------------------------------------------------------------------
# SamplePoints_3D = 10 # Number of sample points in each direction
# SamplePoints_2D = 10 # Number of sample points in each direction
# SamplePoints_3D = 300 # Number of sample points in each direction
# SamplePoints_3D = 150 # Number of sample points in each direction
SamplePoints_3D = 100 # Number of sample points in each direction
# # SamplePoints_3D = 50 # Number of sample points in each direction
# SamplePoints_3D = 25 # Number of sample points in each direction
# SamplePoints_3D = 200 # Number of sample points in each direction
# SamplePoints_3D = 400 # Number of sample points in each direction
# SamplePoints_2D = 7500 # Number of sample points in each direction
# SamplePoints_2D = 4000 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 400 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 1000 # 4000 # Number of sample points in each direction
# SamplePoints_3D = 10 # Number of sample points in each direction
print('NUMBER OF POINTS USED(3D):', SamplePoints_3D)
if make_3D_PhaseDiagram:
alphas_ = np.linspace(-20, 20, SamplePoints_3D)
# alphas_ = np.linspace(-10, 10, SamplePoints_3D)
# betas_ = np.linspace(0.01,40.01,SamplePoints_3D) # Full Range
# betas_ = np.linspace(0.01,20.01,SamplePoints_3D) # FULL Range
# betas_ = np.linspace(0.01,0.99,SamplePoints_3D) # weird part
# betas_ = np.linspace(1.01,40.01,SamplePoints_3D) #TEST !!!!! For Beta <1 weird tings happen...
thetas_ = np.linspace(0.01,0.99,SamplePoints_3D)
#TEST
alphas_ = np.linspace(-5, 15, SamplePoints_3D)
betas_ = np.linspace(1.01,20.01,SamplePoints_3D) #TEST !!!!! For Beta <1 weird tings happen...
# TEST
# alphas_ = np.linspace(-2, 2, SamplePoints_3D)
# betas_ = np.linspace(1.01,10.01,SamplePoints_3D)
# print('betas:', betas_)
# TEST :
# alphas_ = np.linspace(-40, 40, SamplePoints_3D)
# betas_ = np.linspace(0.01,80.01,SamplePoints_3D) # Full Range
# print('type of alphas', type(alphas_))
# print('Test:', type(np.array([mu_gamma])) )
alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
classifyMin_anaVec = np.vectorize(classifyMin_ana)
# Get MuGamma values ...
GetMuGammaVec = np.vectorize(GetMuGamma)
muGammas = GetMuGammaVec(betas, thetas, gamma, mu1, rho1)
# Classify Minimizers....
G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1,True,True) # Sets q12 to zero!!!
# G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1, True, True)
# print('size of G:', G.shape)
# print('G:', G)
# Option to print angles
# print('angles:', angles)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
GammaString = str(gamma)
VTKOutputName = "outputs/PhaseDiagram3D" + "Gamma" + GammaString
gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
print('Written to VTK-File:', VTKOutputName )
if make_2D_PhaseDiagram:
# alphas_ = np.linspace(-20, 20, SamplePoints_2D)
# alphas_ = np.linspace(0, 1, SamplePoints_2D)
thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
alphas_ = np.linspace(-5, 5, SamplePoints_2D)
# alphas_ = np.linspace(-5, 15, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.25,SamplePoints_2D)
# good range:
# alphas_ = np.linspace(9, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.075,0.14,SamplePoints_2D)
# range used:
# alphas_ = np.linspace(8, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.16,SamplePoints_2D)
# alphas_ = np.linspace(8, 12, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.2,SamplePoints_2D)
# betas_ = np.linspace(0.01,40.01,1)
#fix to one value:
betas_ = 2.0;
# betas_ = 10.0;
# betas_ = 5.0;
# betas_ = 0.5;
#intermediate Values
# alphas_ = np.linspace(-2, 1, SamplePoints_2D)
# thetas_ = np.linspace(0.4,0.6,SamplePoints_2D)
# betas_ = 10.0;
# TEST
# alphas_ = np.linspace(-8, 8, SamplePoints_2D)
# thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
# betas_ = 1.0; #TEST Problem: disvison by zero if alpha = 9, theta = 0.1 !
# betas_ = 0.9;
# betas_ = 0.5; #TEST!!!
alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
if generalCase:
classifyMin_matVec = np.vectorize(classifyMin_mat)
GetCellOutputVec = np.vectorize(GetCellOutput, otypes=[np.ndarray, np.ndarray])
Q, B = GetCellOutputVec(alphas,betas,thetas,gamma,mu1,rho1,lambda1, InputFilePath ,OutputFilePath )
# print('type of Q:', type(Q))
# print('Q:', Q)
G, angles, Types, curvature = classifyMin_matVec(Q,B)
else:
classifyMin_anaVec = np.vectorize(classifyMin_ana)
GetMuGammaVec = np.vectorize(GetMuGamma)
muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
G, angles, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# print('size of G:', G.shape)
# print('G:', G)
# print('Types:', Types)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
# VTKOutputName = + path + "./PhaseDiagram2DNEW"
GammaString = str(gamma)
VTKOutputName = "outputs/PhaseDiagram2D" + "Gamma_" + GammaString
gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
print('Written to VTK-File:', VTKOutputName )
# --- Make 3D Scatter plot
if(make_3D_plot or make_2D_plot):
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# ax = plt.axes(projection ='3d', adjustable='box')
# fig,ax = plt.subplots(111, projection='3d')
# ax = plt.axes(projection ='3d', adjustable='box')
colors = cm.plasma(Types)
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=Types.flat)
if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=angles.flat)
if make_3D_plot:
width = 6.28 *0.5
# width = 6.28
# height = width / 1.618
height = width
# pnt3d=ax.scatter(alphas,betas,thetas,c=angles.flatten())
plt.style.use("seaborn")
# plt.style.use("seaborn-paper")
# plt.style.use('ggplot')
# plt.rcParams["font.family"] = "Avenir"
# plt.rcParams["font.size"] = 16
# plt.style.use("seaborn-darkgrid")
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "10"
# mpl.rcParams['xtick.labelsize'] = 16mpl.rcParams['xtick.major.size'] = 2.5
# mpl.rcParams['xtick.bottom'] = True
# mpl.rcParams['ticks'] = True
mpl.rcParams['xtick.bottom'] = True
mpl.rcParams['xtick.major.size'] = 3
mpl.rcParams['xtick.minor.size'] = 1.5
mpl.rcParams['xtick.major.width'] = 0.75
mpl.rcParams['ytick.left'] = True
mpl.rcParams['ytick.major.size'] = 3
mpl.rcParams['ytick.minor.size'] = 1.5
mpl.rcParams['ytick.major.width'] = 0.75
mpl.rcParams.update({'font.size': 10})
mpl.rcParams['axes.labelpad'] = 1
angles = angles.flatten()
cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
cmap=mpl.cm.RdBu_r
# cmap=mpl.cm.viridis_r
# cmap=mpl.cm.bwr
# cmap=mpl.cm.coolwarm
# cmap=mpl.cm.Blues_r
# norm = mpl.colors.Normalize(vmin=5, vmax=10)
# cmap=mpl.cm.gnuplot
# cmap=mpl.cm.magma_r
# cmap=mpl.cm.inferno_r
# cmap=mpl.cm.plasma
# cmap=mpl.cm.plasma_r
# cmap=mpl.cm.cividis_r
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","orange"])
divnorm=mcolors.TwoSlopeNorm(vmin=angles.min(), vcenter=(angles.max()+angles.min())/2, vmax=angles.max())
# cmap = cm.ScalarMappable(norm=divnorm, cmap=cmap)
opacity_list = 1-angles/angles.max()
print('opacity_list', opacity_list)
print('opacity_list.max():', opacity_list.max())
# get a Nx4 array of RGBA corresponding to zs
# cmap expects values between 0 and 1
colors = cmap(angles/angles.max())
# colors = angles/angles.max()
print('colors:', colors)
### set the alpha values according to i_list
### must satisfy 0 <= i <= 1
# epsilon =0.01
opacity_list = np.array(opacity_list)
colors[:,-1] = opacity_list / opacity_list.max()
# ax.scatter(alphas,betas,thetas,c=angles.flatten())
# S = ax.scatter(alphas,betas,thetas,c=colors, cmap=cmap, norm = divnorm)
S = ax.scatter(alphas,betas,thetas,c=colors)
S_2 = ax.scatter(alphas,betas,thetas,c=angles/angles.max(), cmap=cmap, s=0) # Hack for colormap...
# ax.view_init(elev=30, azim=75)
ax.view_init(elev=25, azim=75)
# fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap),
# cax=ax, orientation='horizontal', label='Some Units')
# plt.colorbar(S)
# fig.colorbar(S, ax=ax)
# axins1 = inset_axes(ax,
# width="5%", # width = 5% of parent_bbox width
# height="100%", # height : 50%
# loc='lower left',
# bbox_to_anchor=(1.05, 0., 1, 1),
# bbox_transform=ax[1].transAxes,
# borderpad=0,
# )
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
# cbar = fig.colorbar(S, cax=ax, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(S_2, ax=ax)
# cbar = fig.colorbar(S, ax=ax)
# cbar = fig.colorbar(CS_1, cax=cbar_ax, shrink=0.2, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ax=ax[:], shrink=0.8, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
## ADD COLORBAR:
axins = inset_axes(ax,
width="5%",
height="100%",
loc='right',
borderpad=0,
bbox_to_anchor=[0.0, 0.5]
)
cbar = fig.colorbar(S_2, cax=axins)
# cbar = fig.colorbar(S_2, orientation="horizontal", pad=0.2)
# cbar = fig.colorbar(S_2, pad=0.2)
cbar.ax.set_yticklabels([r'$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$'])
cbar.ax.set_title(r'$\alpha$')
### COLORBAR :
# cbar = plt.colorbar()
# cbar.ax.tick_params(labelsize=10)
# fig.colorbar(S)
# cbar=plt.colorbar(pnt3d)
# cbar.set_label("Values (units)")
# plt.axvline(x = 8, color = 'b', linestyle = ':', label='$q_1$')
# plt.axhline(y = 0.083333333, color = 'b', linestyle = ':', label='$q_1$')
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=angles.flat)
# if make_3D_plot: fig = go.Figure(data=[go.Surface(z=thetas, x=alphas, y=betas, color=angles.flat)])
#### PLOTLY:
# print('angles.flatten()',angles.flatten())
# fig = go.Figure(data=go.Isosurface(
# x=alphas.flatten(),
# y=betas.flatten(),
# z=thetas.flatten(),
# value=angles.flatten(),
# isomin=0,
# isomax=1.565,
# opacity=1.0,
# colorscale='agsunset',
# flatshading = True
# # caps=dict(x_show=False, y_show=False)
# ))
# fig.show()
# ----TEST SAVITZKY_GOLAY FILTER
# zhat = scipy.signal.savgol_filter(angles.flatten(), 5, 4) # window size 51, polynomial order 3
#
# fig = go.Figure(data=go.Volume(
# x=alphas.flatten(),
# y=betas.flatten(),
# z=thetas.flatten(),
# value=zhat,
# isomin=0.0,
# isomax=1.56,
# opacity=0.1, # needs to be small to see through all surfaces
# surface_count=17, # needs to be a large number for good volume rendering
# colorscale='RdBu'
# ))
# fig.show()
## --------------------------------
# alphas = np.array(alphas)
# print('alphas.shape:',np.shape(alphas))
# #### ------- MAYAVI:
# # s = angles.flatten()
# s = angles
# src = mlab.pipeline.scalar_field(s)
# mlab.pipeline.iso_surface(src, contours=[s.min()+0.1*s.ptp(), ], opacity=0.3)
# mlab.pipeline.iso_surface(src, contours=[s.max()-0.1*s.ptp(), ],)
# # mlab.outline()
# # mlab.mesh(alphas,betas,thetas)
# mlab.colorbar( orientation='vertical', nb_labels=5)
# # mlab.orientation_axes()
# mlab.show()
### ---------------
ax.set_xlabel(r'$\theta_\rho$', labelpad=2)
ax.set_ylabel(r"$\theta_\mu$", labelpad=2)
if make_3D_plot: ax.set_zlabel(r'$\theta$',labelpad=2)
fig.set_size_inches(width, height)
# fig.savefig('PhaseDiagram3D.pdf')
fig.savefig('PhaseDiagram3D.png', format='png')
# fig.savefig('Plot-Prestrain-Theta_AlphaFix.pdf',bbox_extra_artists=(cbar,),
# bbox_inches='tight')
# fig.savefig('Plot-Prestrain-Theta_AlphaFix.pdf',format='png',bbox_extra_artists=(cbar,),
# bbox_inches='tight')
# fig.savefig('PhaseDiagram3D', format='svg')
# fig.savefig('PhaseDiagram3D.pdf', dpi=90)
plt.show()
# fig.set_size_inches(width, height)
# fig.savefig('PhaseDiagram3D.pdf')
# plt.savefig('common_labels.png', dpi=300)
# print('T:', T)
# print('Type 1 occured here:', np.where(T == 1))
# print('Type 2 occured here:', np.where(T == 2))
# print(alphas_)
# print(betas_)
# ALTERNATIVE
# colors = ("red", "green", "blue")
# groups = ("Type 1", "Type2", "Type3")
#
# # Create plot
# fig = plt.figure()
# ax = fig.add_subplot(1, 1, 1)
#
# for data, color, group in zip(Types, colors, groups):
# # x, y = data
# ax.scatter(alphas, thetas, alpha=0.8, c=color, edgecolors='none', label=group)
#
# plt.title('Matplot scatter plot')
# plt.legend(loc=2)
# plt.show()
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import time
# print(sys.executable)
# --------------------------------------------------------------------
# START :
# INPUT (Parameters): alpha, beta, theta, gamma, mu1, rho1
#
# -Option 1 : (Case lambda = 0 => q12 = 0)
# compute q1,q2,b1,b2 from Formula
# Option 1.1 :
# set mu_gamma = 'q1' or 'q2' (extreme regimes: gamma \in {0,\infty})
# Option 1.2 :
# compute mu_gamma with 'Compute_MuGamma' (2D problem much faster then Cell-Problem)
# -Option 2 :
# compute Q_hom & B_eff by running 'Cell-Problem'
#
# -> CLASSIFY ...
#
# OUTPUT: Minimizer G, angle , type, curvature
# -----------------------------------------------------------------------
#
#
# def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
# OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
# # ------------------------------------ get mu_gamma ------------------------------
# # ---Scenario 1.1: extreme regimes
# if gamma == '0':
# print('extreme regime: gamma = 0')
# mu_gamma = (1.0/6.0)*arithmeticMean(mu1, beta, theta) # = q2
# print("mu_gamma:", mu_gamma)
# elif gamma == 'infinity':
# print('extreme regime: gamma = infinity')
# mu_gamma = (1.0/6.0)*harmonicMean(mu1, beta, theta) # = q1
# print("mu_gamma:", mu_gamma)
# else:
# # --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# # print("Run computeMuGamma for Gamma = ", gamma)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# # --- Run Cell-Problem
#
# # Check Time
# # t = time.time()
# # subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Cell-Problem_muGama -> faster
# # subprocess.run(['./build-cmake/src/Cell-Problem_muGamma', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Compute_muGamma (2D Problem much much faster)
#
# subprocess.run(['./build-cmake/src/Compute_MuGamma', './inputs/computeMuGamma.parset'],
# capture_output=True, text=True)
# # print('elapsed time:', time.time() - t)
#
# #Extract mu_gamma from Output-File TODO: GENERALIZED THIS FOR QUANTITIES OF INTEREST
# with open(OutputFilePath, 'r') as file:
# output = file.read()
# tmp = re.search(r'(?m)^mu_gamma=.*',output).group() # Not necessary for Intention of Program t output Minimizer etc.....
# s = re.findall(r"[-+]?\d*\.\d+|\d+", tmp)
# mu_gamma = float(s[0])
# # print("mu_gamma:", mu_gammaValue)
# # --------------------------------------------------------------------------------------
# return mu_gamma
#
# ----------- SETUP PATHS
# InputFile = "/inputs/cellsolver.parset"
# OutputFile = "/outputs/output.txt"
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
# -------------------------- Input Parameters --------------------
# mu1 = 10.0 # TODO : here must be the same values as in the Parset for computeMuGamma
mu1 = 1.0
rho1 = 1.0
alpha = 2.0
beta = 2.0
# beta = 5.0
theta = 1.0/4.0
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
# gamma = 'infinity'
# gamma = 0.5
# gamma = 0.25
# gamma = 1.0
# gamma = 5.0
#added
# lambda1 = 10.0
lambda1 = 0.0
#Test:
# rho1 = -1.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
print('alpha: ', alpha)
print('beta: ', beta)
print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
#
# gamma_min = 0.5
# gamma_max = 1.0
#
# # gamma_min = 1
# # gamma_max = 1
# Gamma_Values = np.linspace(gamma_min, gamma_max, num=3)
# # #
# # # Gamma_Values = np.linspace(gamma_min, gamma_max, num=13) # TODO variable Input Parameters...alpha,beta...
# print('(Input) Gamma_Values:', Gamma_Values)
print('type of gamma:', type(gamma))
# # #
# Gamma_Values = ['0', 'infinity']
Gamma_Values = ['infinity']
Gamma_Values = ['0']
print('(Input) Gamma_Values:', Gamma_Values)
for gamma in Gamma_Values:
print('Run for gamma = ', gamma)
print('type of gamma:', type(gamma))
# muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1,InputFilePath)
# # muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1)
# print('Test MuGamma:', muGamma)
# ------- Options --------
# print_Cases = True
# print_Output = True
#TODO
# generalCase = True #Read Output from Cell-Problem instead of using Lemma1.4 (special case)
generalCase = False
# make_3D_plot = True
# make_3D_PhaseDiagram = True
make_2D_plot = False
make_2D_PhaseDiagram = False
make_3D_plot = False
make_3D_PhaseDiagram = False
make_2D_plot = True
make_2D_PhaseDiagram = True
#
# --- Define effective quantities: q1, q2 , q3 = mu_gamma, q12 ---
# q1 = harmonicMean(mu1, beta, theta)
# q2 = arithmeticMean(mu1, beta, theta)
# --- Set q12
# q12 = 0.0 # (analytical example) # TEST / TODO read from Cell-Output
# b1 = prestrain_b1(rho1, beta, alpha, theta)
# b2 = prestrain_b2(rho1, beta, alpha, theta)
#
# print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# print("machine epsilon", sys.float_info.epsilon)
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# ---------------------- MAKE PLOT / Write to VTK------------------------------------------------------------------------------
# SamplePoints_3D = 10 # Number of sample points in each direction
# SamplePoints_2D = 10 # Number of sample points in each direction
SamplePoints_3D = 300 # Number of sample points in each direction
# SamplePoints_3D = 150 # Number of sample points in each direction
# SamplePoints_3D = 100 # Number of sample points in each direction
# SamplePoints_3D = 200 # Number of sample points in each direction
# SamplePoints_3D = 400 # Number of sample points in each direction
# SamplePoints_2D = 7500 # Number of sample points in each direction
# SamplePoints_2D = 4000 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 400 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 500 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 100 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 2000 # 4000 # Number of sample points in each direction
SamplePoints_2D = 1000 # 4000 # Number of sample points in each direction
if make_3D_PhaseDiagram:
alphas_ = np.linspace(-20, 20, SamplePoints_3D)
# alphas_ = np.linspace(-10, 10, SamplePoints_3D)
# betas_ = np.linspace(0.01,40.01,SamplePoints_3D) # Full Range
# betas_ = np.linspace(0.01,20.01,SamplePoints_3D) # FULL Range
# betas_ = np.linspace(0.01,0.99,SamplePoints_3D) # weird part
betas_ = np.linspace(1.01,40.01,SamplePoints_3D) #TEST !!!!! For Beta <1 weird tings happen...
thetas_ = np.linspace(0.01,0.99,SamplePoints_3D)
# TEST
# alphas_ = np.linspace(-2, 2, SamplePoints_3D)
# betas_ = np.linspace(1.01,10.01,SamplePoints_3D)
# print('betas:', betas_)
# TEST :
# alphas_ = np.linspace(-40, 40, SamplePoints_3D)
# betas_ = np.linspace(0.01,80.01,SamplePoints_3D) # Full Range
# print('type of alphas', type(alphas_))
# print('Test:', type(np.array([mu_gamma])) )
alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
classifyMin_anaVec = np.vectorize(classifyMin_ana)
# Get MuGamma values ...
GetMuGammaVec = np.vectorize(GetMuGamma)
muGammas = GetMuGammaVec(betas, thetas, gamma, mu1, rho1)
# Classify Minimizers....
G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1, True, True)
# print('size of G:', G.shape)
# print('G:', G)
# Option to print angles
# print('angles:', angles)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
GammaString = str(gamma)
VTKOutputName = "outputs/PhaseDiagram3D" + "Gamma" + GammaString
gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
print('Written to VTK-File:', VTKOutputName )
if make_2D_PhaseDiagram:
# alphas_ = np.linspace(-20, 20, SamplePoints_2D)
# alphas_ = np.linspace(0, 1, SamplePoints_2D)
thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
alphas_ = np.linspace(-5, 5, SamplePoints_2D)
# alphas_ = np.linspace(-5, 15, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.25,SamplePoints_2D)
# good range:
# alphas_ = np.linspace(9, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.075,0.14,SamplePoints_2D)
# range used:
# alphas_ = np.linspace(8, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.16,SamplePoints_2D)
# alphas_ = np.linspace(8, 12, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.2,SamplePoints_2D)
# betas_ = np.linspace(0.01,40.01,1)
#fix to one value:
betas_ = 2.0;
# betas_ = 10.0;
# betas_ = 5.0;
# betas_ = 0.5;
#intermediate Values
# alphas_ = np.linspace(-2, 1, SamplePoints_2D)
# thetas_ = np.linspace(0.4,0.6,SamplePoints_2D)
# betas_ = 10.0;
# TEST
# alphas_ = np.linspace(-8, 8, SamplePoints_2D)
# thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
# betas_ = 1.0; #TEST Problem: disvison by zero if alpha = 9, theta = 0.1 !
# betas_ = 0.9;
# betas_ = 0.5; #TEST!!!
# alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
betas = betas_
alphas, thetas = np.meshgrid(alphas_, thetas_, indexing='ij')
if generalCase:
classifyMin_matVec = np.vectorize(classifyMin_mat)
GetCellOutputVec = np.vectorize(GetCellOutput, otypes=[np.ndarray, np.ndarray])
Q, B = GetCellOutputVec(alphas,betas,thetas,gamma,mu1,rho1,lambda1, InputFilePath ,OutputFilePath )
# print('type of Q:', type(Q))
# print('Q:', Q)
G, angles, Types, curvature = classifyMin_matVec(Q,B)
else:
classifyMin_anaVec = np.vectorize(classifyMin_ana)
GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# G, angles, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
G, angles, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# print('size of G:', G.shape)
# print('G:', G)
# print('Types:', Types)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
# VTKOutputName = + path + "./PhaseDiagram2DNEW"
print('angles:',angles)
# GammaString = str(gamma)
# VTKOutputName = "outputs/PhaseDiagram2D" + "Gamma_" + GammaString
# gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
# print('Written to VTK-File:', VTKOutputName )
# --- Make 3D Scatter plot
if(make_3D_plot or make_2D_plot):
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# colors = cm.plasma(Types)
colors = cm.coolwarm(angles)
width = 6.28
height = width / 1.618
# height = width / 2.5
fig, ax = plt.subplots()
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=Types.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=Types.flat)
#
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=angles.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=angles.flat)
# pnt=ax.scatter(alphas,thetas,c=angles,cmap='coolwarm')
# # ax.colorbar()
# CS = ax.contourf(alphas, thetas, angles,6, cmap=plt.cm.coolwarm, linestyle=dashed)
# # CS = ax.contour(alphas, thetas, angles,6, colors='k')
# ax.clabel(CS, inline=True, fontsize=7.5)
# # ax.set_title('Simplest default with labels')
if gamma =='0':
CS = ax.contourf(alphas, thetas, angles, 10, cmap=plt.cm.coolwarm)
# CS = ax.contourf(alphas, thetas, angles, 10, cmap='RdBu')
CS2 = ax.contour(CS, levels=CS.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
manual_locations = [
(-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
# ax.clabel(CS2, inline=True, fontsize=6, colors='black', manual=manual_locations)
# ax.clabel(CS2, inline=True, fontsize=6, colors='black')
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
cbar = fig.colorbar(CS, ticks=[0, np.pi/2 ])
cbar.ax.set_yticklabels(['$0$', r'$\pi/2$'])
cbar.ax.set_title(r'angle $\alpha$')
if gamma == 'infinity':
CS = ax.contourf(alphas, thetas, angles, 10, cmap=plt.cm.coolwarm)
# CS = ax.contourf(alphas, thetas, angles, 10, cmap='RdBu')
CS2 = ax.contour(CS, levels=CS.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
manual_locations = [
(-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
ax.clabel(CS2, inline=True, fontsize=6, colors='black', manual=manual_locations)
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
cbar = fig.colorbar(CS, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
cbar.ax.set_yticklabels(['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$'])
cbar.ax.set_title(r'angle $\alpha$')
# cbar=plt.colorbar(pnt3d)
# cbar.set_label("Values (units)")
# plt.axvline(x = 8, color = 'b', linestyle = ':', label='$q_1$')
# plt.axhline(y = 0.083333333, color = 'b', linestyle = ':', label='$q_1$')
ax.set_xlabel(r'$\theta_\rho$',fontsize=10)
# ax.xaxis.set_minor_locator(MultipleLocator(0.5))
ax.yaxis.set_major_locator(MultipleLocator(0.1))
ax.xaxis.set_major_locator(MultipleLocator(1))
# ax.set_ylabel('beta')
ax.set_ylabel(r'$\theta$ ',fontsize=10, rotation=0)
# if make_3D_plot: ax.set_zlabel('theta')
plt.subplots_adjust(bottom=0.2)
plt.grid( linestyle = '--', linewidth = 0.25)
fig.set_size_inches(width, height)
outputName = 'Plot-Contour_Gamma' +str(gamma) + '.pdf'
fig.savefig(outputName)
# fig.savefig('Plot-Contour.pdf')
plt.show()
# plt.savefig('common_labels.png', dpi=300)
# print('T:', T)
# print('Type 1 occured here:', np.where(T == 1))
# print('Type 2 occured here:', np.where(T == 2))
# print(alphas_)
# print(betas_)
# ALTERNATIVE
# colors = ("red", "green", "blue")
# groups = ("Type 1", "Type2", "Type3")
#
# # Create plot
# fig = plt.figure()
# ax = fig.add_subplot(1, 1, 1)
#
# for data, color, group in zip(Types, colors, groups):
# # x, y = data
# ax.scatter(alphas, thetas, alpha=0.8, c=color, edgecolors='none', label=group)
#
# plt.title('Matplot scatter plot')
# plt.legend(loc=2)
# plt.show()
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
from ClassifyMin import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import time
# print(sys.executable)
# --------------------------------------------------------------------
# START :
# INPUT (Parameters): alpha, beta, theta, gamma, mu1, rho1
#
# -Option 1 : (Case lambda = 0 => q12 = 0)
# compute q1,q2,b1,b2 from Formula
# Option 1.1 :
# set mu_gamma = 'q1' or 'q2' (extreme regimes: gamma \in {0,\infty})
# Option 1.2 :
# compute mu_gamma with 'Compute_MuGamma' (2D problem much faster then Cell-Problem)
# -Option 2 :
# compute Q_hom & B_eff by running 'Cell-Problem'
#
# -> CLASSIFY ...
#
# OUTPUT: Minimizer G, angle , type, curvature
# -----------------------------------------------------------------------
#
#
# def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
# OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
# # ------------------------------------ get mu_gamma ------------------------------
# # ---Scenario 1.1: extreme regimes
# if gamma == '0':
# print('extreme regime: gamma = 0')
# mu_gamma = (1.0/6.0)*arithmeticMean(mu1, beta, theta) # = q2
# print("mu_gamma:", mu_gamma)
# elif gamma == 'infinity':
# print('extreme regime: gamma = infinity')
# mu_gamma = (1.0/6.0)*harmonicMean(mu1, beta, theta) # = q1
# print("mu_gamma:", mu_gamma)
# else:
# # --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# # print("Run computeMuGamma for Gamma = ", gamma)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# # --- Run Cell-Problem
#
# # Check Time
# # t = time.time()
# # subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Cell-Problem_muGama -> faster
# # subprocess.run(['./build-cmake/src/Cell-Problem_muGamma', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Compute_muGamma (2D Problem much much faster)
#
# subprocess.run(['./build-cmake/src/Compute_MuGamma', './inputs/computeMuGamma.parset'],
# capture_output=True, text=True)
# # print('elapsed time:', time.time() - t)
#
# #Extract mu_gamma from Output-File TODO: GENERALIZED THIS FOR QUANTITIES OF INTEREST
# with open(OutputFilePath, 'r') as file:
# output = file.read()
# tmp = re.search(r'(?m)^mu_gamma=.*',output).group() # Not necessary for Intention of Program t output Minimizer etc.....
# s = re.findall(r"[-+]?\d*\.\d+|\d+", tmp)
# mu_gamma = float(s[0])
# # print("mu_gamma:", mu_gammaValue)
# # --------------------------------------------------------------------------------------
# return mu_gamma
#
# ----------- SETUP PATHS
# InputFile = "/inputs/cellsolver.parset"
# OutputFile = "/outputs/output.txt"
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
# -------------------------- Input Parameters --------------------
# mu1 = 10.0 # TODO : here must be the same values as in the Parset for computeMuGamma
mu1 = 1.0
rho1 = 1.0
alpha = 2.0
beta = 2.0
# beta = 5.0
theta = 1.0/4.0
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
# gamma = 'infinity'
# gamma = 0.5
# gamma = 0.25
# gamma = 1.0
# gamma = 5.0
#added
# lambda1 = 10.0
lambda1 = 0.0
#Test:
# rho1 = -1.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
print('alpha: ', alpha)
print('beta: ', beta)
print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
#
# gamma_min = 0.5
# gamma_max = 1.0
#
# # gamma_min = 1
# # gamma_max = 1
# Gamma_Values = np.linspace(gamma_min, gamma_max, num=3)
# # #
# # # Gamma_Values = np.linspace(gamma_min, gamma_max, num=13) # TODO variable Input Parameters...alpha,beta...
# print('(Input) Gamma_Values:', Gamma_Values)
print('type of gamma:', type(gamma))
# # #
Gamma_Values = ['0', 'infinity']
# Gamma_Values = ['infinity']
# Gamma_Values = ['0']
print('(Input) Gamma_Values:', Gamma_Values)
for gamma in Gamma_Values:
print('Run for gamma = ', gamma)
print('type of gamma:', type(gamma))
# muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1,InputFilePath)
# # muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1)
# print('Test MuGamma:', muGamma)
# ------- Options --------
# print_Cases = True
# print_Output = True
#TODO
# generalCase = True #Read Output from Cell-Problem instead of using Lemma1.4 (special case)
generalCase = False
# make_3D_plot = True
# make_3D_PhaseDiagram = True
make_2D_plot = False
make_2D_PhaseDiagram = False
make_3D_plot = False
make_3D_PhaseDiagram = False
make_2D_plot = True
make_2D_PhaseDiagram = True
#
# --- Define effective quantities: q1, q2 , q3 = mu_gamma, q12 ---
# q1 = harmonicMean(mu1, beta, theta)
# q2 = arithmeticMean(mu1, beta, theta)
# --- Set q12
# q12 = 0.0 # (analytical example) # TEST / TODO read from Cell-Output
# b1 = prestrain_b1(rho1, beta, alpha, theta)
# b2 = prestrain_b2(rho1, beta, alpha, theta)
#
# print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# print("machine epsilon", sys.float_info.epsilon)
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# ---------------------- MAKE PLOT / Write to VTK------------------------------------------------------------------------------
# SamplePoints_3D = 10 # Number of sample points in each direction
# SamplePoints_2D = 10 # Number of sample points in each direction
SamplePoints_3D = 300 # Number of sample points in each direction
# SamplePoints_3D = 150 # Number of sample points in each direction
# SamplePoints_3D = 100 # Number of sample points in each direction
# SamplePoints_3D = 200 # Number of sample points in each direction
# SamplePoints_3D = 400 # Number of sample points in each direction
# SamplePoints_2D = 7500 # Number of sample points in each direction
# SamplePoints_2D = 4000 # 4000 # Number of sample points in each direction
SamplePoints_2D = 400 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 500 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 100 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 2000 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 1000 # 4000 # Number of sample points in each direction
if make_3D_PhaseDiagram:
alphas_ = np.linspace(-20, 20, SamplePoints_3D)
# alphas_ = np.linspace(-10, 10, SamplePoints_3D)
# betas_ = np.linspace(0.01,40.01,SamplePoints_3D) # Full Range
# betas_ = np.linspace(0.01,20.01,SamplePoints_3D) # FULL Range
# betas_ = np.linspace(0.01,0.99,SamplePoints_3D) # weird part
betas_ = np.linspace(1.01,40.01,SamplePoints_3D) #TEST !!!!! For Beta <1 weird tings happen...
thetas_ = np.linspace(0.01,0.99,SamplePoints_3D)
# TEST
# alphas_ = np.linspace(-2, 2, SamplePoints_3D)
# betas_ = np.linspace(1.01,10.01,SamplePoints_3D)
# print('betas:', betas_)
# TEST :
# alphas_ = np.linspace(-40, 40, SamplePoints_3D)
# betas_ = np.linspace(0.01,80.01,SamplePoints_3D) # Full Range
# print('type of alphas', type(alphas_))
# print('Test:', type(np.array([mu_gamma])) )
alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
classifyMin_anaVec = np.vectorize(classifyMin_ana)
# Get MuGamma values ...
GetMuGammaVec = np.vectorize(GetMuGamma)
muGammas = GetMuGammaVec(betas, thetas, gamma, mu1, rho1)
# Classify Minimizers....
G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1, True, True)
# print('size of G:', G.shape)
# print('G:', G)
# Option to print angles
# print('angles:', angles)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
GammaString = str(gamma)
VTKOutputName = "outputs/PhaseDiagram3D" + "Gamma" + GammaString
gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
print('Written to VTK-File:', VTKOutputName )
if make_2D_PhaseDiagram:
# alphas_ = np.linspace(-20, 20, SamplePoints_2D)
# alphas_ = np.linspace(0, 1, SamplePoints_2D)
thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
alphas_ = np.linspace(-5, 5, SamplePoints_2D)
# alphas_ = np.linspace(-5, 15, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.25,SamplePoints_2D)
# good range:
# alphas_ = np.linspace(9, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.075,0.14,SamplePoints_2D)
# range used:
# alphas_ = np.linspace(8, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.16,SamplePoints_2D)
# alphas_ = np.linspace(8, 12, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.2,SamplePoints_2D)
# betas_ = np.linspace(0.01,40.01,1)
#fix to one value:
betas_ = 2.0;
# betas_ = 10.0;
# betas_ = 5.0;
# betas_ = 0.5;
#intermediate Values
alphas_ = np.linspace(-2, 1, SamplePoints_2D)
# thetas_ = np.linspace(0.4,0.6,SamplePoints_2D)
# betas_ = 10.0;
# TEST
# alphas_ = np.linspace(-8, 8, SamplePoints_2D)
# thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
# betas_ = 1.0; #TEST Problem: disvison by zero if alpha = 9, theta = 0.1 !
# betas_ = 0.9;
# betas_ = 0.5; #TEST!!!
# alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
betas = betas_
alphas, thetas = np.meshgrid(alphas_, thetas_, indexing='ij')
if generalCase:
classifyMin_matVec = np.vectorize(classifyMin_mat)
GetCellOutputVec = np.vectorize(GetCellOutput, otypes=[np.ndarray, np.ndarray])
Q, B = GetCellOutputVec(alphas,betas,thetas,gamma,mu1,rho1,lambda1, InputFilePath ,OutputFilePath )
# print('type of Q:', type(Q))
# print('Q:', Q)
G, angles, Types, curvature = classifyMin_matVec(Q,B)
else:
classifyMin_anaVec = np.vectorize(classifyMin_ana)
GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# G, angles, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
if gamma == '0':
G, angles_0, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
if gamma == 'infinity':
G, angles_inf, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# print('size of G:', G.shape)
# print('G:', G)
# print('Types:', Types)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
# VTKOutputName = + path + "./PhaseDiagram2DNEW"
# print('angles:',angles)
# GammaString = str(gamma)
# VTKOutputName = "outputs/PhaseDiagram2D" + "Gamma_" + GammaString
# gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
# print('Written to VTK-File:', VTKOutputName )
# --- Make 3D Scatter plot
if(make_3D_plot or make_2D_plot):
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# colors = cm.plasma(Types)
colors = cm.coolwarm(angles_inf)
width = 6.28
# height = width / 1.618
height = width / 2.5
# fig, ax = plt.subplots()
fig,ax = plt.subplots(nrows=1,ncols=2,figsize=(width,height), sharey=True)
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=Types.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=Types.flat)
#
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=angles.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=angles.flat)
# pnt=ax.scatter(alphas,thetas,c=angles,cmap='coolwarm')
# # ax.colorbar()
# CS = ax.contourf(alphas, thetas, angles,6, cmap=plt.cm.coolwarm, linestyle=dashed)
# # CS = ax.contour(alphas, thetas, angles,6, colors='k')
# ax.clabel(CS, inline=True, fontsize=7.5)
# # ax.set_title('Simplest default with labels')
# matplotlib.rcParams['contour.linestyles'] = 'dashed'
CS_0 = ax[0].contourf(alphas, thetas, angles_0, 10, cmap=plt.cm.coolwarm)
# CS = ax.contourf(alphas, thetas, angles, 10, cmap='RdBu')
CS_02 = ax[0].contour(CS_0, levels=CS_0.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
# manual_locations = [
# (-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
manual_locations = [
(-0.4, 0.2),(-0.6, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
# ax.clabel(CS2, inline=True, fontsize=6, colors='black', manual=manual_locations)
# ax.clabel(CS2, inline=True, fontsize=6, colors='black')
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_0, ticks=[0, np.pi/2 ])
# cbar.ax.set_yticklabels(['$0$', r'$\pi/2$'])
# cbar.ax.set_title(r'angle $\alpha$')
CS_1 = ax[1].contourf(alphas, thetas, angles_inf, 10, cmap=plt.cm.coolwarm)
# CS = ax.contourf(alphas, thetas, angles, 10, cmap='RdBu')
CS_12 = ax[1].contour(CS_1, levels=CS_1.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
# manual_locations = [
# (-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
manual_locations = [
(-0.5, 0.15), (-0.7, 0.3), (-0.8, 0.45), (-0.9, 0.6), (-1,0.75)]
# ax[1].clabel(CS_12, inline=True, fontsize=10, colors='black', manual=manual_locations)
ax[1].clabel(CS_12, inline=True, fontsize=8, colors='black', manual=manual_locations)
# ax[1].clabel(CS_12, inline=True, fontsize=8, colors='black')
axins1 = inset_axes(ax[1],
width="5%", # width = 5% of parent_bbox width
height="100%", # height : 50%
loc='lower left',
bbox_to_anchor=(1.05, 0., 1, 1),
bbox_transform=ax[1].transAxes,
borderpad=0,
)
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
cbar = fig.colorbar(CS_1, cax=axins1, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, cax=cbar_ax, shrink=0.2, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ax=ax[:], shrink=0.8, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
cbar.ax.set_yticklabels(['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$'])
# cbar.ax.set_title(r'angle $\alpha$')
cbar.ax.set_title(r'$\alpha$')
# cbar=plt.colorbar(pnt3d)
# cbar.set_label("Values (units)")
# plt.axvline(x = 8, color = 'b', linestyle = ':', label='$q_1$')
# plt.axhline(y = 0.083333333, color = 'b', linestyle = ':', label='$q_1$')
ax[0].set_xlabel(r'$\theta_\rho$',fontsize=10)
# ax[0].yaxis.set_major_locator(MultipleLocator(0.1))
# ax[0].xaxis.set_major_locator(MultipleLocator(1))
ax[0].yaxis.set_major_locator(MultipleLocator(0.1))
ax[0].xaxis.set_major_locator(MultipleLocator(0.5))
ax[0].set_ylabel(r'$\theta$ ',fontsize=10, rotation=0)
ax[0].tick_params(axis='x', labelsize=7 )
ax[0].tick_params(axis='y', labelsize=7 )
ax[1].set_xlabel(r'$\theta_\rho$',fontsize=10)
# ax.xaxis.set_minor_locator(MultipleLocator(0.5))
# ax[1].yaxis.set_major_locator(MultipleLocator(0.1))
# ax[1].xaxis.set_major_locator(MultipleLocator(1))
ax[1].yaxis.set_major_locator(MultipleLocator(0.1))
ax[1].xaxis.set_major_locator(MultipleLocator(0.5))
ax[1].tick_params(axis='x', labelsize=7 )
ax[1].tick_params(axis='y', labelsize=7 )
# ax.set_ylabel('beta')
# ax[1].set_ylabel(r'$\theta$ ',fontsize=10, rotation=0)
# if make_3D_plot: ax.set_zlabel('theta')
# plt.subplots_adjust(bottom=0.2)
# plt.subplots_adjust(wspace=0.22, hspace=0.1)
plt.subplots_adjust(hspace=0.15, wspace=0.1)
plt.subplots_adjust(bottom=0.2)
# fig.subplots_adjust(right=0.75)
ax[0].grid( linestyle = '--', linewidth = 0.25)
ax[1].grid( linestyle = '--', linewidth = 0.25)
fig.set_size_inches(width, height)
outputName = 'Plot-Contour_Gamma' +str(gamma) + '.pdf'
fig.savefig(outputName)
# fig.savefig('Plot-Contour.pdf')
plt.show()
# plt.savefig('common_labels.png', dpi=300)
# print('T:', T)
# print('Type 1 occured here:', np.where(T == 1))
# print('Type 2 occured here:', np.where(T == 2))
# print(alphas_)
# print(betas_)
# ALTERNATIVE
# colors = ("red", "green", "blue")
# groups = ("Type 1", "Type2", "Type3")
#
# # Create plot
# fig = plt.figure()
# ax = fig.add_subplot(1, 1, 1)
#
# for data, color, group in zip(Types, colors, groups):
# # x, y = data
# ax.scatter(alphas, thetas, alpha=0.8, c=color, edgecolors='none', label=group)
#
# plt.title('Matplot scatter plot')
# plt.legend(loc=2)
# plt.show()
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
import math
import os
import subprocess
import fileinput
import re
import matlab.engine
import sys
# from ClassifyMin import *
from ClassifyMin_New import *
from HelperFunctions import *
# from CellScript import *
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from vtk.util import numpy_support
from pyevtk.hl import gridToVTK
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import matplotlib as mpl
import seaborn as sns
import matplotlib.colors as mcolors
import time
from scipy.ndimage.filters import gaussian_filter
# from scipy import ndimage
# print(sys.executable)
# --------------------------------------------------------------------
# START :
# INPUT (Parameters): alpha, beta, theta, gamma, mu1, rho1
#
# -Option 1 : (Case lambda = 0 => q12 = 0)
# compute q1,q2,b1,b2 from Formula
# Option 1.1 :
# set mu_gamma = 'q1' or 'q2' (extreme regimes: gamma \in {0,\infty})
# Option 1.2 :
# compute mu_gamma with 'Compute_MuGamma' (2D problem much faster then Cell-Problem)
# -Option 2 :
# compute Q_hom & B_eff by running 'Cell-Problem'
#
# -> CLASSIFY ...
#
# OUTPUT: Minimizer G, angle , type, curvature
# -----------------------------------------------------------------------
#
#
# def GetMuGamma(beta,theta,gamma,mu1,rho1, InputFilePath = os.path.dirname(os.getcwd()) +"/inputs/computeMuGamma.parset",
# OutputFilePath = os.path.dirname(os.getcwd()) + "/outputs/outputMuGamma.txt" ):
# # ------------------------------------ get mu_gamma ------------------------------
# # ---Scenario 1.1: extreme regimes
# if gamma == '0':
# print('extreme regime: gamma = 0')
# mu_gamma = (1.0/6.0)*arithmeticMean(mu1, beta, theta) # = q2
# print("mu_gamma:", mu_gamma)
# elif gamma == 'infinity':
# print('extreme regime: gamma = infinity')
# mu_gamma = (1.0/6.0)*harmonicMean(mu1, beta, theta) # = q1
# print("mu_gamma:", mu_gamma)
# else:
# # --- Scenario 1.2: compute mu_gamma with 'Compute_MuGamma' (much faster than running full Cell-Problem)
# # print("Run computeMuGamma for Gamma = ", gamma)
# with open(InputFilePath, 'r') as file:
# filedata = file.read()
# filedata = re.sub('(?m)^gamma=.*','gamma='+str(gamma),filedata)
# # filedata = re.sub('(?m)^alpha=.*','alpha='+str(alpha),filedata)
# filedata = re.sub('(?m)^beta=.*','beta='+str(beta),filedata)
# filedata = re.sub('(?m)^theta=.*','theta='+str(theta),filedata)
# filedata = re.sub('(?m)^mu1=.*','mu1='+str(mu1),filedata)
# filedata = re.sub('(?m)^rho1=.*','rho1='+str(rho1),filedata)
# f = open(InputFilePath,'w')
# f.write(filedata)
# f.close()
# # --- Run Cell-Problem
#
# # Check Time
# # t = time.time()
# # subprocess.run(['./build-cmake/src/Cell-Problem', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Cell-Problem_muGama -> faster
# # subprocess.run(['./build-cmake/src/Cell-Problem_muGamma', './inputs/cellsolver.parset'],
# # capture_output=True, text=True)
# # --- Run Compute_muGamma (2D Problem much much faster)
#
# subprocess.run(['./build-cmake/src/Compute_MuGamma', './inputs/computeMuGamma.parset'],
# capture_output=True, text=True)
# # print('elapsed time:', time.time() - t)
#
# #Extract mu_gamma from Output-File TODO: GENERALIZED THIS FOR QUANTITIES OF INTEREST
# with open(OutputFilePath, 'r') as file:
# output = file.read()
# tmp = re.search(r'(?m)^mu_gamma=.*',output).group() # Not necessary for Intention of Program t output Minimizer etc.....
# s = re.findall(r"[-+]?\d*\.\d+|\d+", tmp)
# mu_gamma = float(s[0])
# # print("mu_gamma:", mu_gammaValue)
# # --------------------------------------------------------------------------------------
# return mu_gamma
#
# ----------- SETUP PATHS
# InputFile = "/inputs/cellsolver.parset"
# OutputFile = "/outputs/output.txt"
InputFile = "/inputs/computeMuGamma.parset"
OutputFile = "/outputs/outputMuGamma.txt"
# --------- Run from src folder:
path_parent = os.path.dirname(os.getcwd())
os.chdir(path_parent)
path = os.getcwd()
print(path)
InputFilePath = os.getcwd()+InputFile
OutputFilePath = os.getcwd()+OutputFile
print("InputFilepath: ", InputFilePath)
print("OutputFilepath: ", OutputFilePath)
print("Path: ", path)
# -------------------------- Input Parameters --------------------
# mu1 = 10.0 # TODO : here must be the same values as in the Parset for computeMuGamma
mu1 = 1.0
rho1 = 1.0
alpha = 2.0
beta = 2.0
# beta = 5.0
theta = 1.0/4.0
#set gamma either to 1. '0' 2. 'infinity' or 3. a numerical positive value
gamma = '0'
# gamma = 'infinity'
# gamma = 0.5
# gamma = 0.25
# gamma = 1.0
# gamma = 5.0
#added
# lambda1 = 10.0
lambda1 = 0.0
#Test:
# rho1 = -1.0
print('---- Input parameters: -----')
print('mu1: ', mu1)
print('rho1: ', rho1)
print('alpha: ', alpha)
print('beta: ', beta)
print('theta: ', theta)
print('gamma:', gamma)
print('lambda1: ', lambda1)
print('----------------------------')
# ----------------------------------------------------------------
#
# gamma_min = 0.5
# gamma_max = 1.0
#
# # gamma_min = 1
# # gamma_max = 1
# Gamma_Values = np.linspace(gamma_min, gamma_max, num=3)
# # #
# # # Gamma_Values = np.linspace(gamma_min, gamma_max, num=13) # TODO variable Input Parameters...alpha,beta...
# print('(Input) Gamma_Values:', Gamma_Values)
print('type of gamma:', type(gamma))
# # #
Gamma_Values = ['0', 'infinity']
# Gamma_Values = ['infinity']
# Gamma_Values = ['0']
print('(Input) Gamma_Values:', Gamma_Values)
for gamma in Gamma_Values:
print('Run for gamma = ', gamma)
print('type of gamma:', type(gamma))
# muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1,InputFilePath)
# # muGamma = GetMuGamma(beta,theta,gamma,mu1,rho1)
# print('Test MuGamma:', muGamma)
# ------- Options --------
# print_Cases = True
# print_Output = True
#TODO
# generalCase = True #Read Output from Cell-Problem instead of using Lemma1.4 (special case)
generalCase = False
# make_3D_plot = True
# make_3D_PhaseDiagram = True
make_2D_plot = False
make_2D_PhaseDiagram = False
make_3D_plot = False
make_3D_PhaseDiagram = False
make_2D_plot = True
make_2D_PhaseDiagram = True
#
# --- Define effective quantities: q1, q2 , q3 = mu_gamma, q12 ---
# q1 = harmonicMean(mu1, beta, theta)
# q2 = arithmeticMean(mu1, beta, theta)
# --- Set q12
# q12 = 0.0 # (analytical example) # TEST / TODO read from Cell-Output
# b1 = prestrain_b1(rho1, beta, alpha, theta)
# b2 = prestrain_b2(rho1, beta, alpha, theta)
#
# print('---- Input parameters: -----')
# print('mu1: ', mu1)
# print('rho1: ', rho1)
# print('alpha: ', alpha)
# print('beta: ', beta)
# print('theta: ', theta)
# print("q1: ", q1)
# print("q2: ", q2)
# print("mu_gamma: ", mu_gamma)
# print("q12: ", q12)
# print("b1: ", b1)
# print("b2: ", b2)
# print('----------------------------')
# print("machine epsilon", sys.float_info.epsilon)
# G, angle, type, kappa = classifyMin(q1, q2, mu_gamma, q12, b1, b2, print_Cases, print_Output)
# Test = f(1,2 ,q1,q2,mu_gamma,q12,b1,b2)
# print("Test", Test)
# ---------------------- MAKE PLOT / Write to VTK------------------------------------------------------------------------------
# SamplePoints_3D = 10 # Number of sample points in each direction
# SamplePoints_2D = 10 # Number of sample points in each direction
SamplePoints_3D = 300 # Number of sample points in each direction
# SamplePoints_3D = 150 # Number of sample points in each direction
# SamplePoints_3D = 100 # Number of sample points in each direction
# SamplePoints_3D = 200 # Number of sample points in each direction
# SamplePoints_3D = 400 # Number of sample points in each direction
# SamplePoints_2D = 7500 # Number of sample points in each direction
# SamplePoints_2D = 4000 # 4000 # Number of sample points in each direction
SamplePoints_2D = 400 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 500 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 100 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 2000 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 1000 # 4000 # Number of sample points in each direction
# SamplePoints_2D = 1500 # 4000 # Number of sa
if make_3D_PhaseDiagram:
alphas_ = np.linspace(-20, 20, SamplePoints_3D)
# alphas_ = np.linspace(-10, 10, SamplePoints_3D)
# betas_ = np.linspace(0.01,40.01,SamplePoints_3D) # Full Range
# betas_ = np.linspace(0.01,20.01,SamplePoints_3D) # FULL Range
# betas_ = np.linspace(0.01,0.99,SamplePoints_3D) # weird part
betas_ = np.linspace(1.01,40.01,SamplePoints_3D) #TEST !!!!! For Beta <1 weird tings happen...
thetas_ = np.linspace(0.01,0.99,SamplePoints_3D)
# TEST
# alphas_ = np.linspace(-2, 2, SamplePoints_3D)
# betas_ = np.linspace(1.01,10.01,SamplePoints_3D)
# print('betas:', betas_)
# TEST :
# alphas_ = np.linspace(-40, 40, SamplePoints_3D)
# betas_ = np.linspace(0.01,80.01,SamplePoints_3D) # Full Range
# print('type of alphas', type(alphas_))
# print('Test:', type(np.array([mu_gamma])) )
alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
classifyMin_anaVec = np.vectorize(classifyMin_ana)
# Get MuGamma values ...
GetMuGammaVec = np.vectorize(GetMuGamma)
muGammas = GetMuGammaVec(betas, thetas, gamma, mu1, rho1)
# Classify Minimizers....
G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# G, angles, Types, curvature = classifyMin_anaVec(alphas, betas, thetas, muGammas, mu1, rho1, True, True)
# print('size of G:', G.shape)
# print('G:', G)
# Option to print angles
# print('angles:', angles)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
GammaString = str(gamma)
VTKOutputName = "outputs/PhaseDiagram3D" + "Gamma" + GammaString
gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
print('Written to VTK-File:', VTKOutputName )
if make_2D_PhaseDiagram:
# alphas_ = np.linspace(-20, 20, SamplePoints_2D)
# alphas_ = np.linspace(0, 1, SamplePoints_2D)
thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
alphas_ = np.linspace(-5, 5, SamplePoints_2D)
# alphas_ = np.linspace(-5, 15, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.25,SamplePoints_2D)
# good range:
# alphas_ = np.linspace(9, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.075,0.14,SamplePoints_2D)
# range used:
# alphas_ = np.linspace(8, 10, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.16,SamplePoints_2D)
# alphas_ = np.linspace(8, 12, SamplePoints_2D)
# thetas_ = np.linspace(0.05,0.2,SamplePoints_2D)
# betas_ = np.linspace(0.01,40.01,1)
#fix to one value:
betas_ = 2.0;
# betas_ = 10.0;
# betas_ = 5.0;
# betas_ = 0.5;
#intermediate Values
alphas_ = np.linspace(-2, 1, SamplePoints_2D)
# alphas_ = np.linspace(-1.5, 1, SamplePoints_2D)
# thetas_ = np.linspace(0.4,0.6,SamplePoints_2D)
# betas_ = 10.0;
# TEST
# alphas_ = np.linspace(-8, 8, SamplePoints_2D)
# thetas_ = np.linspace(0.01,0.99,SamplePoints_2D)
# betas_ = 1.0; #TEST Problem: disvison by zero if alpha = 9, theta = 0.1 !
# betas_ = 0.9;
# betas_ = 0.5; #TEST!!!
# alphas, betas, thetas = np.meshgrid(alphas_, betas_, thetas_, indexing='ij')
betas = betas_
alphas, thetas = np.meshgrid(alphas_, thetas_, indexing='ij')
if generalCase:
classifyMin_matVec = np.vectorize(classifyMin_mat)
GetCellOutputVec = np.vectorize(GetCellOutput, otypes=[np.ndarray, np.ndarray])
Q, B = GetCellOutputVec(alphas,betas,thetas,gamma,mu1,rho1,lambda1, InputFilePath ,OutputFilePath )
# print('type of Q:', type(Q))
# print('Q:', Q)
G, angles, Types, curvature = classifyMin_matVec(Q,B)
else:
classifyMin_anaVec = np.vectorize(classifyMin_ana)
GetMuGammaVec = np.vectorize(GetMuGamma)
# muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
# G, angles, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
muGammas = GetMuGammaVec(betas,thetas,gamma,mu1,rho1,InputFilePath ,OutputFilePath )
if gamma == '0':
G, angles_0, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
if gamma == 'infinity':
G, angles_inf, Types, curvature = classifyMin_anaVec(alphas,betas,thetas, muGammas, mu1, rho1) # Sets q12 to zero!!!
# print('size of G:', G.shape)
# print('G:', G)
# print('Types:', Types)
# Out = classifyMin_anaVec(alphas,betas,thetas)
# T = Out[2]
# --- Write to VTK
# VTKOutputName = + path + "./PhaseDiagram2DNEW"
# print('angles:',angles)
# GammaString = str(gamma)
# VTKOutputName = "outputs/PhaseDiagram2D" + "Gamma_" + GammaString
# gridToVTK(VTKOutputName , alphas, betas, thetas, pointData = {'Type': Types, 'angles': angles, 'curvature': curvature} )
# print('Written to VTK-File:', VTKOutputName )
# --- Make 3D Scatter plot
if(make_3D_plot or make_2D_plot):
# Styling
plt.style.use("seaborn-darkgrid")
plt.style.use("seaborn-whitegrid")
plt.style.use("seaborn")
# plt.style.use("seaborn-paper")
# plt.style.use('ggplot')
# plt.rcParams["font.family"] = "Avenir"
# plt.rcParams["font.size"] = 16
# plt.style.use("seaborn-darkgrid")
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "10"
# mpl.rcParams['xtick.labelsize'] = 16mpl.rcParams['xtick.major.size'] = 2.5
# mpl.rcParams['xtick.bottom'] = True
# mpl.rcParams['ticks'] = True
mpl.rcParams['xtick.bottom'] = True
mpl.rcParams['xtick.major.size'] = 3
mpl.rcParams['xtick.minor.size'] = 1.5
mpl.rcParams['xtick.major.width'] = 0.75
mpl.rcParams['ytick.left'] = True
mpl.rcParams['ytick.major.size'] = 3
mpl.rcParams['ytick.minor.size'] = 1.5
mpl.rcParams['ytick.major.width'] = 0.75
mpl.rcParams.update({'font.size': 10})
### ADJUST GRID:
mpl.rcParams['axes.labelpad'] = 5
mpl.rcParams['grid.linewidth'] = 0.25
mpl.rcParams['grid.alpha'] = 0.9 # 0.75
mpl.rcParams['grid.linestyle'] = '-'
mpl.rcParams['grid.color'] = 'gray'#'black'
# mpl.rcParams['axes.axisbelow'] = True
# mpl.rcParams.update({"axes.grid" : True, "grid.color": "gray"})
# mpl.rcParams["axes.grid"] = False
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# colors = cm.plasma(Types)
colors = cm.coolwarm(angles_inf)
width = 6.28
# height = width / 1.618
height = width / 2.5
# height = width
# fig, ax = plt.subplots()
fig,ax = plt.subplots(nrows=1,ncols=2,figsize=(width,height), sharey=True)
# ax = plt.axes((0.15,0.21 ,0.8,0.75))
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=Types.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=Types.flat)
#
# if make_2D_plot: pnt3d=ax.scatter(alphas,thetas,c=angles.flat)
# if make_3D_plot: pnt3d=ax.scatter(alphas,betas,thetas,c=angles.flat)
# pnt=ax.scatter(alphas,thetas,c=angles,cmap='coolwarm')
# # ax.colorbar()
# CS = ax.contourf(alphas, thetas, angles,6, cmap=plt.cm.coolwarm, linestyle=dashed)
# # CS = ax.contour(alphas, thetas, angles,6, colors='k')
# ax.clabel(CS, inline=True, fontsize=7.5)
# # ax.set_title('Simplest default with labels')
# matplotlib.rcParams['contour.linestyles'] = 'dashed'
cmap=mpl.cm.coolwarm
# cmap = sns.color_palette("flare", as_cmap=True)
# cmap = sns.color_palette('species')
### GET COLORS :
deep_colors = sns.color_palette("pastel")
print('deep_colors.as_hex():',deep_colors.as_hex())
diverging_colors = sns.color_palette("RdBu", 10)
print('diverging_colors.as_hex():',diverging_colors.as_hex())
pal = sns.color_palette("Blues")
pal = sns.color_palette()
print(pal.as_hex())
# flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
flatui = ["coral","white", "cornflowerblue"]
flatui = ["cornflowerblue", "coral"]
flatui = ['#4c72b0','white', '#c44e52']
flatui = ['#4c72b0','white', '#8de5a1']
flatui = ['#a1c9f4', '#ffb482','#ff9f9b'] #Test colors
flatui = ['#4c72b0','white', '#ffb482']
flatui = ['#4c72b0','white', '#ff9f9b']
flatui = ['#4c72b0','white', '#ab162a']
# flatui = ['#4c72b0','white', '#eb9172']
# flatui = ['#4c72b0','white', '#64b5cd']
cmap = mpl.colors.ListedColormap(sns.color_palette(flatui).as_hex())
cmap = mpl.colors.ListedColormap(sns.color_palette(flatui).as_hex())
cmap = mpl.colors.ListedColormap(sns.color_palette("RdBu_r", 10).as_hex())
cmap = mpl.colors.ListedColormap(sns.color_palette("coolwarm", 10).as_hex()) #Discrete CMAP
cmap = sns.color_palette("coolwarm", as_cmap=True)
# cmap = sns.color_palette("vlag", as_cmap=True)
# cmap = sns.color_palette("icefire", as_cmap=True)
# cmap = sns.color_palette("Spectral_r", as_cmap=True)
# cmap = sns.color_palette("flare_r", as_cmap=True)
# cmap = sns.diverging_palette(220, 20, as_cmap=True)
# cmap = sns.diverging_palette(250, 30, l=65, center="dark", as_cmap=True)
# cmap = mpl.colors.ListedColormap(sns.color_palette().as_hex())
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", sns.color_palette(flatui).as_hex())
### REVERSE COLORMAP :
# cmap = mpl.colors.ListedColormap(cmap.colors[::-1])
# cmap = cmap.reverse()
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["blue","violet","red"])
# cmap = mpl.colors.LinearSegmentedColormap.from_list("", ["cornflowerblue","coral"])
# plt.imshow(angles_0, extent=[-2, 1, 0, 1],origin='lower',
# cmap=cmap, alpha=1.0)
divnorm=mcolors.TwoSlopeNorm(vmin=angles_0.min(), vcenter=(angles_0.max()+angles_0.min())/2, vmax=angles_0.max())
ax[0].imshow(angles_0.T, extent=[-2, 1, 0, 1], origin='lower', norm = divnorm,
cmap=cmap, alpha=0.9, aspect=2.5)
# CS = ax[0].contour(alphas, thetas, angles_0, colors='k',linewidths=(0.75), extent=(-2, 1, 0, 1), zorder=5)
levels = np.arange(0.0, 1.58, 1)
# angles_0 = gaussian_filter(angles_0, sigma=0.1) # Try to smooth contour
# CS = ax[0].contour(alphas, thetas, angles_0, levels, colors='k',linewidths=(0.75), extent=(-2, 1, 0, 1), zorder=5)
# CS = ax[0].contour(alphas, thetas, angles_0, levels=[0.0], colors='black',linewidths=(0.75), extent=(-2, 1, 0, 1), zorder=5)
CS = ax[0].contour(alphas, thetas, angles_0, levels=1, colors='black',linewidths=(0.5), extent=(-2, 1, 0, 1), zorder=5)
# ax[0].clabel(CS, inline=True, fontsize=8, colors='black')
# manual_locations = [(-0.75, 0.2),(0.5,0.6)]
# ax[0].clabel(CS, inline=True, fontsize=8, colors='black', manual=manual_locations)
# CS_0 = ax[0].contourf(alphas, thetas, angles_0, 10, cmap=plt.cm.coolwarm)
# CS_02 = ax[0].contour(CS_0, levels=CS_0.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
# manual_locations = [
# (-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
manual_locations = [
(-0.4, 0.2),(-0.6, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
# ax.clabel(CS2, inline=True, fontsize=6, colors='black', manual=manual_locations)
# ax.clabel(CS2, inline=True, fontsize=6, colors='black')
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_0, ticks=[0, np.pi/2 ])
# cbar.ax.set_yticklabels(['$0$', r'$\pi/2$'])
# cbar.ax.set_title(r'angle $\alpha$')
divnorm=mcolors.TwoSlopeNorm(vmin=angles_inf.min(), vcenter=(angles_inf.max()+angles_inf.min())/2, vmax=angles_inf.max())
Im = ax[1].imshow(angles_inf.T, extent=[-2, 1, 0, 1], origin='lower', norm = divnorm,
cmap=cmap, alpha=0.9, aspect=2.5)
# CS_1 = ax[1].contour(alphas, thetas, angles_inf, colors='k',linewidths=(0.75), extent=(-2, 1, 0, 1), zorder=5)
levels = np.arange(0.25, 1.6, 0.25)
# levels = np.arange(0.1, 1.58, 0.25)
# angles_inf = gaussian_filter(angles_inf, sigma=2) # Try to smooth contour
CS_1 = ax[1].contour(alphas, thetas, angles_inf,levels, colors='black',linewidths=(0.5), extent=(-2, 1, 0, 1), zorder=5)
# ax[1].clabel(CS_1, inline=True, fontsize=8, colors='black')
# manual_locations = [
# (-0.5, 0.15), (-0.7, 0.3), (-0.8, 0.45), (-0.9, 0.6), (-1,0.75)]
manual_locations = [
(-0.4, 0.1), (-0.6,0.30), (-0.7, 0.45), (-0.8, 0.6), (-0.9, 0.75), (-1,0.90)]
ax[1].clabel(CS_1, inline=True, fontsize=10, colors='black', manual=manual_locations)
# CS_1 = ax[1].contourf(alphas, thetas, angles_inf, 10, cmap=plt.cm.coolwarm)
# # CS = ax.contourf(alphas, thetas, angles, 10, cmap='RdBu')
# CS_12 = ax[1].contour(CS_1, levels=CS_1.levels[::2], colors='black',inline=True, linewidths=(0.5,))
# # ax.clabel(CS2, inline=True, fontsize=9, colors='black')
# # ax.clabel(CS2, inline=True, inline_spacing=3, rightside_up=True, colors='k', fontsize=8)
# # manual_locations = [
# # (-0.5, 0.3), (-0.7, 0.4), (-0.8, 0.5), (-0.9, 0.6), (-1,0.7)]
# manual_locations = [
# (-0.5, 0.15), (-0.7, 0.3), (-0.8, 0.45), (-0.9, 0.6), (-1,0.75)]
# # ax[1].clabel(CS_12, inline=True, fontsize=10, colors='black', manual=manual_locations)
# ax[1].clabel(CS_12, inline=True, fontsize=8, colors='black', manual=manual_locations)
# # ax[1].clabel(CS_12, inline=True, fontsize=8, colors='black')
axins1 = inset_axes(ax[1],
width="5%", # width = 5% of parent_bbox width
height="100%", # height : 50%
loc='lower left',
bbox_to_anchor=(1.05, 0., 1, 1),
bbox_transform=ax[1].transAxes,
borderpad=0,
)
# ax.clabel(CS2, CS2.levels, inline=True, fontsize=10)
# ax.clabel(CS, fontsize=5, colors='black')
# cbar = fig.colorbar(CS,label=r'angle $\alpha$', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
cbar = fig.colorbar(Im, cax=axins1, ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, cax=cbar_ax, shrink=0.2, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
# cbar = fig.colorbar(CS_1, ax=ax[:], shrink=0.8, location='right', ticks=[0, np.pi/8, np.pi/4, 3*np.pi/8 , np.pi/2 ])
cbar.ax.set_yticklabels(['$0$',r'$\pi/8$', r'$\pi/4$' ,r'$3\pi/8$' , r'$\pi/2$'])
# cbar.ax.set_title(r'angle $\alpha$')
# cbar.ax.set_title(r'angle $\alpha$', fontsize=10)
cbar.ax.set_title(r'$\alpha$', fontsize=10)
# cbar=plt.colorbar(pnt3d)
# cbar.set_label("Values (units)")
# plt.axvline(x = 8, color = 'b', linestyle = ':', label='$q_1$')
# plt.axhline(y = 0.083333333, color = 'b', linestyle = ':', label='$q_1$')
ax[0].set_xlabel(r'$\theta_\rho$',fontsize=10)
# ax[0].yaxis.set_major_locator(MultipleLocator(0.1))
# ax[0].xaxis.set_major_locator(MultipleLocator(1))
ax[0].yaxis.set_major_locator(MultipleLocator(0.1))
ax[0].xaxis.set_major_locator(MultipleLocator(0.5))
ax[0].set_ylabel(r'$\theta$ ',fontsize=10, rotation=0, labelpad=10)
ax[0].tick_params(axis='x', labelsize=10 )
ax[0].tick_params(axis='y', labelsize=10)
ax[0].set_title(r"$0<\gamma\ll1$")
ax[1].set_xlabel(r'$\theta_\rho$',fontsize=10)
# ax.xaxis.set_minor_locator(MultipleLocator(0.5))
# ax[1].yaxis.set_major_locator(MultipleLocator(0.1))
# ax[1].xaxis.set_major_locator(MultipleLocator(1))
ax[1].yaxis.set_major_locator(MultipleLocator(0.1))
ax[1].xaxis.set_major_locator(MultipleLocator(0.5))
ax[1].tick_params(axis='x', labelsize=10 )
ax[1].tick_params(axis='y', labelsize=10 )
ax[1].set_title(r"$\gamma \gg 1$")
# ax.set_ylabel('beta')
# ax[1].set_ylabel(r'$\theta$ ',fontsize=10, rotation=0)
# if make_3D_plot: ax.set_zlabel('theta')
# plt.subplots_adjust(bottom=0.2)
# plt.subplots_adjust(wspace=0.22, hspace=0.1)
plt.subplots_adjust(hspace=0.15, wspace=0.1)
plt.subplots_adjust(bottom=0.2)
# fig.subplots_adjust(right=0.75)
# ax[0].grid( linestyle = '-', linewidth = 0.25, alpha=0.5, zorder=1)
# ax[1].grid( linestyle = '--', linewidth = 0.25, zorder=1)
# ax[1].set_axisbelow(True)
# ax[1].yaxis.grid(color='gray', linestyle='dashed')
# # Hide grid lines
# ax.grid(False)
fig.set_size_inches(width, height)
outputName = '2D-PhaseDiagram-Angle.pdf'
fig.savefig(outputName, dpi=300, format='pdf')
# fig.savefig('Plot-Contour.pdf')
plt.show()
# plt.savefig('common_labels.png', dpi=300)
# print('T:', T)
# print('Type 1 occured here:', np.where(T == 1))
# print('Type 2 occured here:', np.where(T == 2))
# print(alphas_)
# print(betas_)
# ALTERNATIVE
# colors = ("red", "green", "blue")
# groups = ("Type 1", "Type2", "Type3")
#
# # Create plot
# fig = plt.figure()
# ax = fig.add_subplot(1, 1, 1)
#
# for data, color, group in zip(Types, colors, groups):
# # x, y = data
# ax.scatter(alphas, thetas, alpha=0.8, c=color, edgecolors='none', label=group)
#
# plt.title('Matplot scatter plot')
# plt.legend(loc=2)
# plt.show()