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 15074 additions and 0 deletions
Matlab-Programs/resources/previewImage.png

18.8 KiB

File added
Matlab-Programs/resources/screenshot.png

17 KiB

function [G, angle, Type, kappa] = symMinimization(print_Input,print_statPoint,print_Output,make_FunctionPlot, InputPath) %(Q_hom,B_eff)
syms v1 v2 q1 q2 q3 q12 b1 b2 b3
% -------- Options ----------
% % print_Input = false; %effective quantities
% print_Input = true;
% % print_statPoint = false;
% print_statPoint = true;
% print_Minimizer = true;
% % make_FunctionPlot = false;
% make_FunctionPlot = true;
print_Uniqueness = false;
check_StationaryPoints = false; % could be added to Input-Parameters..
compare_with_Classification = false; %maybe added later ---
%fprintf('Functions to be minimized:')
f_plus(v1,v2,q1,q2,q3,q12,b1,b2,b3) = q1*v1^4 + q2*v2^4+2*q3*v1^2*v2^2-2*(q1*b1*v1^2+ q2*b2*v2^2+sqrt(2)*q3*b3*v1*v2)...
+ q12*(v1^2*v2^2-b2*v1^2-b1*v2^2+b1*b2);
f_minus(v1,v2,q1,q2,q3,q12,b1,b2,b3) = q1*v1^4 + q2*v2^4+2*q3*v1^2*v2^2+2*(q1*b1*v1^2+ q2*b2*v2^2+sqrt(2)*q3*b3*v1*v2)...
+ q12*(v1^2*v2^2+b2*v1^2+b1*v2^2+b1*b2);
% ---- Fix parameters
% Epsilon used:
epsilon = 1e-8;
if ~exist('InputPath','var')
% third parameter does not exist, so default it to something
absPath = "/home/klaus/Desktop/DUNE/dune-microstructure/outputs";
end
% 1. Import effective quantities from CellSolver-Code:
%read as sparse Matrix...
try %absolutePath
Qmat = spconvert(load(absPath + '' + "/QMatrix.txt"));
Bmat = spconvert(load(absPath + '' + "/BMatrix.txt"));
% fprintf('Use absolute Path')
catch ME % use relativePath
Qmat = spconvert(load('../outputs/QMatrix.txt'));
Bmat = spconvert(load('../outputs/BMatrix.txt'));
% fprintf('Use relative Path')
end
%convert to full matrix...
Qmat = full(Qmat);
Bmat = full(Bmat);
% --- TODO CHECK: assert if Q is orthotropic ??? check ifq13=q31=q23=q32= 0 ?
if print_Input
fprintf('effective quadratic form:')
Qmat
fprintf('effective prestrain')
Bmat
% check if Q is (close to..) symmetric
% könnte Anti-symmetric part berechnen und schauen dass dieser klein?
% Test: issymmetric(Qmat) does not work for float matrices?
% symmetric part 0.5*(Qmat+Qmat')
% anti-symmetric part 0.5*(Qmat-Qmat')
if norm(0.5*(Qmat-Qmat'),'fro') < 1e-8
fprintf('Qmat (close to) symmetric \n')
norm(0.5*(Qmat-Qmat'),'fro') % TEST
else
fprintf('Qmat not symmetric \n')
end
% Check if B_eff is diagonal this is equivalent to b3 == 0
if abs(Bmat(3)) < 1e-8
fprintf('B_eff is diagonal (b3 == 0) \n')
else
fprintf('B_eff is NOT diagonal (b3 != 0) \n')
end
end
% CAST VALUES TO SYM FIRST? This is done anyway..
% % Substitute effective quantitites
f_plus = subs(f_plus,{q1, q2, q3, q12, b1, b2, b3}, {Qmat(1,1), Qmat(2,2), Qmat(3,3), Qmat(1,2), ...
Bmat(1), Bmat(2), Bmat(3)});
f_minus = subs(f_minus,{q1, q2, q3, q12, b1, b2, b3}, {Qmat(1,1), Qmat(2,2), Qmat(3,3), Qmat(1,2), ...
Bmat(1), Bmat(2), Bmat(3)});
% Compute the Gradients
df_plusx = diff(f_plus,v1);
df_plusy = diff(f_plus,v2);
df_minusx = diff(f_minus,v1);
df_minusy = diff(f_minus,v2);
% Setup Equations Grad(f) = 0
eq1 = df_plusx == 0;
eq2 = df_plusy == 0;
eqns_plus = [eq1, eq2];
eq3 = df_minusx == 0;
eq4 = df_minusy == 0;
eqns_minus = [eq3, eq4];
% ------- Symbolically Solve Equations:
% More robust (works even for values b_3 ~ 1e-08 ):
S_plus = solve(eqns_plus,v1,v2,'MaxDegree' , 5);
S_minus = solve(eqns_minus,v1,v2,'MaxDegree' , 5);
A_plus = S_plus.v1;
B_plus = S_plus.v2;
A_minus = S_minus.v1;
B_minus = S_minus.v2;
if check_StationaryPoints
%---------- TEST if Grad(f) = 0 ---------------------
fprintf('Testing equation grad(f) = 0 with stationary points')
for i = 1:size(A_plus,1)
fprintf('Testing %d.point (f_plus): ',i )
[ double(subs(subs(df_plusx,v1,A_plus(i)),v2,B_plus(i))), double(subs(subs(df_plusy,v1,A_plus(i)),v2,B_plus(i))) ]
end
for i = 1:size(A_minus,1)
fprintf('Testing %d.point (f_minus): ',i )
[double(subs(subs(df_minusx,v1,A_minus(i)),v2,B_minus(i))), double(subs(subs(df_minusy,v1,A_minus(i)),v2,B_minus(i)))]
end
% ------------------------------------
end
% --- Extract only Real-Solutions
% fprintf('real stationary points of f_plus:')
tmp1 = A_plus(imag(double(A_plus))==0 & imag(double(B_plus)) == 0);
tmp2 = B_plus(imag(double(A_plus))==0 & imag(double(B_plus)) == 0);
A_plus = tmp1;
B_plus = tmp2;
SP_plus = [A_plus,B_plus];
% fprintf('real stationary points of f_minus:')
tmp1 = A_minus(imag(double(A_minus))==0 & imag(double(B_minus)) == 0);
tmp2 = B_minus(imag(double(A_minus))==0 & imag(double(B_minus)) == 0);
A_minus = tmp1;
B_minus = tmp2;
SP_minus = [A_minus,B_minus];
% TODO one should use f_plus.subs(A_plus..) to compute function value symbolically?
% in the end only the stationaryPoints are used.. should be ok to compare function values numerically
% Determine global Minimizer from stationary points:
% fprintf('function values at stationary points (f_plus):')
T_plus = arrayfun(@(v1,v2) double(f_plus(v1,v2,q1,q2,q3,q12,b1,b2,b3)),A_plus,B_plus,'UniformOutput', false);
T_plus = cell2mat(T_plus);
%Test: use Substitution
% subs(f_plus,{v1, v2}, {A_plus,B_plus})
% fprintf('function values at stationary points (f_minus):')
T_minus = arrayfun(@(v1,v2) double(f_minus(v1,v2,q1,q2,q3,q12,b1,b2,b3)),A_minus,B_minus,'UniformOutput', false);
T_minus = cell2mat(T_minus);
%Test: use Substitution
% T_minus = subs(f_minus,{v1, v2}, {A_minus,B_minus})
% double(T_minus)
if print_statPoint
fprintf('real stationary points of f_plus: ')
% SP_Plus %alternative: output as symbolic (can be unwieldy)
double(SP_plus)
fprintf('real stationary points of f_minus:')
% SP_Minus %alternative: output as symbolic (can be unwieldy)
double(SP_minus)
fprintf('function values at stationary points (f_plus):')
T_plus
fprintf('function values at stationary points (f_minus):')
T_minus
end
% --- Find Stationary Point(s) with minimum Value
[Min_plus,MinIdx_plus] = min(T_plus, [], 'all', 'linear'); %find one min...
[Min_minus,MinIdx_minus] = min(T_minus, [], 'all', 'linear');
% [Min_minus,MinIdx_minus] = min(T_minus) % works with symbolic too
% Compare Minimizers of f_plus & f_minus
[globalMinimizerValue,GlobalIdx] = min([Min_plus,Min_minus]);
if GlobalIdx == 1 %Min_plus % i.e. Global Minimizer is given by f_plus
GlobalMinimizer = SP_plus(MinIdx_plus,:);
sign = 1.0;
elseif GlobalIdx == 2 %Min_minus % i.e. Global Minimizer is given by f_minus
GlobalMinimizer = SP_minus(MinIdx_minus,:);
sign = -1.0;
end
% ------ Check if there are more SP with the same value...
MinIndices_minus = find(T_minus(:) == globalMinimizerValue); % Find indices of All Minima
MinIndices_plus = find(T_plus(:) == globalMinimizerValue); % Find indices of All Minima
numMinSP_minus = size(MinIndices_minus,1); % One of these is always >= 2 due to the structure of the roots..
numMinSP_plus = size(MinIndices_plus,1);
% AllMinSP_minus = SP_minus(MinIndices_minus,:)
% AllMinSP_minus = double(SP_minus(MinIndices_minus,:))
% AllMin = T_minus(MinIndices) %bereits klar dass diese selben funktionswert haben..
Minimizer = sign*(GlobalMinimizer'*GlobalMinimizer); % global minimizing Matrix G*
MinimizerCount = 1;
% different Stationary Points might correspond to the same minimizing
% Matrix G*... check this:
% Compare only with other StationaryPoints/Minimizers
% remove Index of Minimizer
if GlobalIdx == 1
MinIndices_plus = MinIndices_plus(MinIndices_plus~=MinIdx_plus);
elseif GlobalIdx == 2
MinIndices_minus = MinIndices_minus(MinIndices_minus~=MinIdx_minus);
end
MinIndices = cat(1,MinIndices_plus,MinIndices_minus); %[Minimizers-Indices f_plus, Minimizer-Indices f_minus]
for i = 1:(numMinSP_minus+numMinSP_plus-1) % -1: dont count Minimizer itself..
idx = MinIndices(i);
if i > numMinSP_plus
SP = SP_minus(idx,:);
else
SP = SP_plus(idx,:);
end
% SP_value = T_minus(idx) % not needed?
Matrix = sign*(SP'*SP);
if norm(double(Matrix-Minimizer),'fro') < 1e-8 %check is this sufficient here?
% fprintf('both StationaryPoints correspond to the same(Matrix-)Minimizer')
else
% fprintf('StationaryPoint corresponds to a different (Matrix-)Minimizer')
MinimizerCount = MinimizerCount + 1;
end
end
% ----------------------------------------------------------------------------------------------------------------
% Output Uniqueness of Minimizers:
if print_Uniqueness
if MinimizerCount == 1
fprintf('Unique Minimzier')
elseif MinimizerCount == 2
fprintf('Two Minimziers')
else
fprintf('1-Parameter family of Minimziers')
end
end
% --- determine the angle of the Minimizer
% a1 = Minimizer(1,1)
% a2 = Minimizer(2,2)
a1 = double(Minimizer(1,1));
a2 = double(Minimizer(2,2));
% compute the angle <(e,e_1) where Minimizer = kappa* (e (x) e)
e = [sqrt((a1/(a1+a2))), sqrt((a2/(a1+a2)))]; % always positive under sqrt here .. basically takes absolute value here
angle = atan2(e(2), e(1));
% compute curvature kappa
kappa = (a1 + a2);
% % CHeck off diagonal entries:
% sqrt(a1*a2);
% double(Minimizer);
G = double(Minimizer);
% --- "Classification" / Determine the TYPE of Minimizer by using
% the number of solutions (Uniqueness?)
% the angle (axial- or non-axial Minimizer)
% (Alternative compute det[GlobalMinimizer' e1'] where e1 = [1 0] ?)
% Check Uniqueness -- Options: unique/twoMinimizers/1-ParameterFamily
if MinimizerCount == 1
% fprintf('Unique Minimzier')
% Check if Minimizer is axial or non-axial:
if (abs(angle-pi/2) < 1e-8 || abs(angle) < 1e-8) % axial Minimizer
Type = 3;
else % non-axial Minimizer
Type = 1;
end
elseif MinimizerCount == 2
% fprintf('Two Minimziers')
% Check if Minimizer is axial or non-axial:
if (abs(angle-pi/2) < 1e-8 || abs(angle) < 1e-8) % axial Minimizer
Type = 3;
else % non-axial Minimizer
fprintf('ERROR: Two non-axial Minimizers cannot happen!')
end
else
% fprintf('1-Parameter family of Minimziers')
% Check if Minimizer is axial or non-axial:
if (abs(angle-pi/2) < 1e-8 || abs(angle) < 1e-8) % axial Minimizer
% fprintf('ERROR: axial Minimizers cannot happen for 1-Parameter Family!')
else % non-axial Minimizer
Type = 2;
end
end
% ------------------------------------------------------------------------------------------------------
if print_Output
fprintf(' --------- Output symMinimization --------')
fprintf('Global Minimizer v: (%d,%d) \n', GlobalMinimizer(1),GlobalMinimizer(2) )
fprintf('Global Minimizer Value f(v): %d \n', sym(globalMinimizerValue) ) %cast to symbolic
% fprintf('Global Minimizer Value : %d', globalMinimizerValue )
fprintf('Global Minimizer G: \n' )
G
fprintf("Angle = %d \n", angle)
fprintf("Curvature = %d \n", kappa)
fprintf("Type = %i \n", Type)
fprintf(' --------- -------------------- --------')
end
if make_FunctionPlot
fsurf(@(x,y) f_plus(x,y,q1,q2,q3,q12,b1,b2,b3)) % Plot functions
hold on
plot3(double(A_plus),double(B_plus),T_plus,'g*')
%Plot GlobalMinimizer:
hold on
plot3(double(GlobalMinimizer(1)),double(GlobalMinimizer(2)),globalMinimizerValue, 'o', 'Color','c')
% view(90,0)
% view(2)
figure
fsurf(@(x,y) f_minus(x,y,q1,q2,q3,q12,b1,b2,b3))
hold on
plot3(double(A_minus),double(B_minus),T_minus,'g*')
hold on
plot3(double(GlobalMinimizer(1)), double(GlobalMinimizer(2)),globalMinimizerValue, 'o', 'Color','c')
end
return
% Write symbolic solution to txt-File in Latex format
% fileID = fopen('txt.txt','w');
% fprintf(fileID,'%s' , latex(S_plus.v1));
% fclose(fileID);
syms q1 q2 q3 q12 b1 b2 a1 a2
% eqn1 = q1 * a1 + (q3 + (q12/2)) *a2 == -2*q1*b1 - q12*b2
%
% eqn2 = (q3 + (q12/2)) * a1 + q2 *a2 == -2*q2*b2 - q12*b1
eqn1 = q1 * a1 + (q3 + (q12/2)) *a2 == q1*b1 + (q12*b2/2)
eqn2 = (q3 + (q12/2)) * a1 + q2 *a2 == q2*b2 + (q12*b1/2)
[A,B] = equationsToMatrix([eqn1, eqn2], [a1,a2])
X = linsolve(A,B)
% check special case
fprintf('special case q12 = 0 ')
subs(X,q12,0)
\ No newline at end of file
Colormap: Cool-to-Warm
Representation: Point-Gaussian
Opacity: 0.01
PointSize: 2
Gaussian-radius: 0.0075
Shader-Preset: Plain-Circle
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)
################################################################################################################
################################################################################################################
################################################################################################################
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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
print('T:', T)
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
e_container = []
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 ]
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]
e_container.append(e)
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
G_container = np.array(G_container)
abar_container = np.array(abar_container)
e_container = np.array(e_container)
print('G_container', G_container)
print('G_container.shape', G_container.shape)
# idx_1 = np.where(alphas == np.pi/4)
idx_1 = np.where(np.round(alphas,2) == round(np.pi/3,2))
idx_2 = np.where(np.round(alphas,2) == 0.0)
idx_3 = np.where(np.round(alphas,2) == round(np.pi/4,2))
# idx_3 = np.where(alphas == 0)
print('Index idx_1:', idx_1)
print('Index idx_2:', idx_2)
print('Index idx_3:', idx_3)
print('Index idx_1[0][0]:', idx_1[0][0])
print('Index idx_2[0][0]:', idx_2[0][0])
print('Index idx_3[0][0]:', idx_3[0][0])
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('kappas:',kappas)
# print('alphas:',alphas)
print('min alpha:', min(alphas))
print('min kappa:', min(kappas))
print('G_container[idx_1[0][0]]', G_container[idx_1[0][0]])
print('G_container[idx_2[0][0]]', G_container[idx_2[0][0]])
print('G_container[idx_3[0][0]]', G_container[idx_3[0][0]])
print('e_container[idx_1[0][0]]', e_container[idx_1[0][0]])
print('e_container[idx_2[0][0]]', e_container[idx_2[0][0]])
print('e_container[idx_3[0][0]]', e_container[idx_3[0][0]])
idx = 2
e = e_container[idx_1[0][0]]
e = e_container[idx_2[0][0]]
# e = e_container[idx_3[0][0]]
kappa = kappas[idx_1[0][0]]
kappa = kappas[idx_2[0][0]]
# kappa = kappas[idx_3[0][0]]
angle = alphas[idx_1[0][0]]
angle = alphas[idx_2[0][0]]
# angle = alphas[idx_3[0][0]]
# kappa = kappa*2
print('kappa:',kappa)
print('angle:',angle)
#### TEST apply reflection
#
# G_tmp = G_container[idx_1[0][0]]
#
# print('G_tmp', G_tmp)
#
# # Basis:
# G_1 = np.array([[1.0,0.0], [0.0,0.0]])
# G_2 = np.array([[0.0,0.0], [0.0,1.0]])
# G_3 = (1/np.sqrt(2))*np.array([[0.0,1.0], [1.0,0.0]])
# print('G_1', G_1)
# print('G_2', G_2)
# print('G_3', G_3)
#
# G = G_tmp[0] * G_1 + G_tmp[1]*G_2 + G_tmp[2]*G_3
# print('G:', G )
#
# T = np.array([[1.0 , -1.0] , [-1.0,1.0]])
#
# TG = np.multiply(T,G)
# print('TG', TG)
#
#
#
# v = np.array([np.sqrt(TG[0][0]),np.sqrt(TG[1][1]) ])
# print('v', v)
# print('norm(v):', np.linalg.norm(v))
# norm_v = np.linalg.norm(v)
#
# kappa = norm_v**2
#
# e = (1/norm_v)*v
# print('e:', e)
# print('kappa:', kappa)
reflected_e = np.array([e[0], -1*e[1]])
e = reflected_e # Correct?! Reflect e on x-Axis ??!
print('reflected_e:', reflected_e)
############################################################################################################################################
####################################################################### 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(-2,2,num_Points)
x = np.linspace(-3,3,num_Points)
# x = np.linspace(-4,4,num_Points)
# 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)
y = np.linspace(-1/4,1/4,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 * 0.333
height = width / 1.618
height = width / 2.5
height = width
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)
###---- 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)
# 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 = 10, cstride = 10, facecolors=cm.brg(colorfunction), alpha=.8, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 5, cstride = 5, color='orange', alpha=.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color='blue', alpha=.8, zorder=4, shade=True)
# 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)
# Plot 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=5) # line width
# 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]
# 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() /12
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /8
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /6
# 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)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-1.5, (mid_u2 + max_range)+1.5)
# ax.autoscale(tight=True)
##----- 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)
ax.view_init(elev=25, azim=-30)
# 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)
Figurename = r'1-ParFamMinimizer_idx' + str(idx)
# 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 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)
################################################################################################################
################################################################################################################
################################################################################################################
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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
print('T:', T)
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
e_container = []
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 ]
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]
e_container.append(e)
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
G_container = np.array(G_container)
abar_container = np.array(abar_container)
e_container = np.array(e_container)
print('G_container', G_container)
print('G_container.shape', G_container.shape)
# idx_1 = np.where(alphas == np.pi/4)
idx_1 = np.where(np.round(alphas,2) == round(np.pi/3,2))
idx_2 = np.where(np.round(alphas,2) == 0.0)
idx_3 = np.where(np.round(alphas,2) == round(np.pi/4,2))
# idx_3 = np.where(alphas == 0)
print('Index idx_1:', idx_1)
print('Index idx_2:', idx_2)
print('Index idx_3:', idx_3)
print('Index idx_1[0][0]:', idx_1[0][0])
print('Index idx_2[0][0]:', idx_2[0][0])
print('Index idx_3[0][0]:', idx_3[0][0])
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('kappas:',kappas)
# print('alphas:',alphas)
print('min alpha:', min(alphas))
print('min kappa:', min(kappas))
print('G_container[idx_1[0][0]]', G_container[idx_1[0][0]])
print('G_container[idx_2[0][0]]', G_container[idx_2[0][0]])
print('G_container[idx_3[0][0]]', G_container[idx_3[0][0]])
print('e_container[idx_1[0][0]]', e_container[idx_1[0][0]])
print('e_container[idx_2[0][0]]', e_container[idx_2[0][0]])
print('e_container[idx_3[0][0]]', e_container[idx_3[0][0]])
idx = 2
e = e_container[idx_1[0][0]]
e = e_container[idx_2[0][0]]
# e = e_container[idx_3[0][0]]
kappa = kappas[idx_1[0][0]]
kappa = kappas[idx_2[0][0]]
# kappa = kappas[idx_3[0][0]]
angle = alphas[idx_1[0][0]]
angle = alphas[idx_2[0][0]]
# angle = alphas[idx_3[0][0]]
# kappa = kappa*2
print('kappa:',kappa)
print('angle:',angle)
#### TEST apply reflection
#
# G_tmp = G_container[idx_1[0][0]]
#
# print('G_tmp', G_tmp)
#
# # Basis:
# G_1 = np.array([[1.0,0.0], [0.0,0.0]])
# G_2 = np.array([[0.0,0.0], [0.0,1.0]])
# G_3 = (1/np.sqrt(2))*np.array([[0.0,1.0], [1.0,0.0]])
# print('G_1', G_1)
# print('G_2', G_2)
# print('G_3', G_3)
#
# G = G_tmp[0] * G_1 + G_tmp[1]*G_2 + G_tmp[2]*G_3
# print('G:', G )
#
# T = np.array([[1.0 , -1.0] , [-1.0,1.0]])
#
# TG = np.multiply(T,G)
# print('TG', TG)
#
#
#
# v = np.array([np.sqrt(TG[0][0]),np.sqrt(TG[1][1]) ])
# print('v', v)
# print('norm(v):', np.linalg.norm(v))
# norm_v = np.linalg.norm(v)
#
# kappa = norm_v**2
#
# e = (1/norm_v)*v
# print('e:', e)
# print('kappa:', kappa)
reflected_e = np.array([e[0], -1*e[1]])
e = reflected_e # Correct?! Reflect e on x-Axis ??!
print('reflected_e:', reflected_e)
############################################################################################################################################
####################################################################### 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(-2,2,num_Points)
x = np.linspace(-3,3,num_Points)
# x = np.linspace(-4,4,num_Points)
# 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)
y = np.linspace(-1/4,1/4,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 * 0.333
height = width / 1.618
height = width / 2.5
height = width
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)
###---- 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)
# 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 = 10, cstride = 10, facecolors=cm.brg(colorfunction), alpha=.8, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 5, cstride = 5, color='orange', alpha=.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color='blue', alpha=.8, zorder=4, shade=True)
# 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)
# Plot 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=5) # line width
# 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]
# 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() /12
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /8
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /6
# 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)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-1.5, (mid_u2 + max_range)+1.5)
# ax.autoscale(tight=True)
##----- 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)
ax.view_init(elev=25, azim=-30)
# 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)
Figurename = r'1-ParFamMinimizer_idx' + str(idx)
# 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 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
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)
################################################################################################################
################################################################################################################
################################################################################################################
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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
print('T:', T)
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
e_container = []
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 ]
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]
e_container.append(e)
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
G_container = np.array(G_container)
abar_container = np.array(abar_container)
e_container = np.array(e_container)
print('G_container', G_container)
print('G_container.shape', G_container.shape)
# idx_1 = np.where(alphas == np.pi/4)
idx_1 = np.where(np.round(alphas,2) == round(np.pi/3,2))
idx_2 = np.where(np.round(alphas,2) == 0.0)
idx_3 = np.where(np.round(alphas,2) == round(np.pi/4,2))
# idx_3 = np.where(alphas == 0)
print('Index idx_1:', idx_1)
print('Index idx_2:', idx_2)
print('Index idx_3:', idx_3)
print('Index idx_1[0][0]:', idx_1[0][0])
print('Index idx_2[0][0]:', idx_2[0][0])
print('Index idx_3[0][0]:', idx_3[0][0])
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('kappas:',kappas)
# print('alphas:',alphas)
print('min alpha:', min(alphas))
print('min kappa:', min(kappas))
print('G_container[idx_1[0][0]]', G_container[idx_1[0][0]])
print('G_container[idx_2[0][0]]', G_container[idx_2[0][0]])
print('G_container[idx_3[0][0]]', G_container[idx_3[0][0]])
print('e_container[idx_1[0][0]]', e_container[idx_1[0][0]])
print('e_container[idx_2[0][0]]', e_container[idx_2[0][0]])
print('e_container[idx_3[0][0]]', e_container[idx_3[0][0]])
###################################################
reflect = False
# reflect = True
idx = 3
if idx == 1 :
e = e_container[idx_1[0][0]]
kappa = kappas[idx_1[0][0]]
angle = alphas[idx_1[0][0]]
reflect = True
if idx == 2 :
e = e_container[idx_2[0][0]]
kappa = kappas[idx_2[0][0]]
angle = alphas[idx_2[0][0]]
if idx == 3 :
e = e_container[idx_3[0][0]]
kappa = kappas[idx_3[0][0]]
angle = alphas[idx_3[0][0]]
### SCALE ?
# kappa = kappa*2
print('kappa:',kappa)
print('angle:',angle)
###################################################
#### TEST apply reflection
#
# G_tmp = G_container[idx_1[0][0]]
#
# print('G_tmp', G_tmp)
#
# # Basis:
# G_1 = np.array([[1.0,0.0], [0.0,0.0]])
# G_2 = np.array([[0.0,0.0], [0.0,1.0]])
# G_3 = (1/np.sqrt(2))*np.array([[0.0,1.0], [1.0,0.0]])
# print('G_1', G_1)
# print('G_2', G_2)
# print('G_3', G_3)
#
# G = G_tmp[0] * G_1 + G_tmp[1]*G_2 + G_tmp[2]*G_3
# print('G:', G )
#
# T = np.array([[1.0 , -1.0] , [-1.0,1.0]])
#
# TG = np.multiply(T,G)
# print('TG', TG)
#
#
#
# v = np.array([np.sqrt(TG[0][0]),np.sqrt(TG[1][1]) ])
# print('v', v)
# print('norm(v):', np.linalg.norm(v))
# norm_v = np.linalg.norm(v)
#
# kappa = norm_v**2
#
# e = (1/norm_v)*v
# print('e:', e)
# print('kappa:', kappa)
if reflect == True:
reflected_e = np.array([e[0], -1*e[1]])
e = reflected_e # Correct?! Reflect e on x-Axis ??!
print('reflected_e:', reflected_e)
############################################################################################################################################
####################################################################### 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(-2,2,num_Points)
x = np.linspace(-2.5,2.5,num_Points)
x = np.linspace(-3,3,num_Points)
# x = np.linspace(-4,4,num_Points)
# 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)
y = np.linspace(-1/4,1/4,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 * 0.333
height = width / 1.618
height = width / 2.5
height = width
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)
# if idx == 1:
# Rotation = rot(np.array([1,0,0]),np.pi)
# Rotation = rot(np.array([1,0,0]),np.pi).dot(rot(np.array([0,0,1]),angle))
Rotation = rot(np.array([1,0,0]),np.pi)
# 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(Rotation)
Rotation = rot(np.array([1,0,0]),np.pi).dot(rot(np.array([0,0,1]),angle))
# 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)
# Rotation = rot(np.array([0,0,1]),np.pi/2).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)
###---- 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 = 10, cstride = 10, facecolors=cm.brg(colorfunction), alpha=.8, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 5, cstride = 5, color='orange', alpha=.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color='blue', alpha=.8, zorder=4, shade=True)
# 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)
# Plot 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=5) # line width
#midpoint:
endpoint = np.array([min(x),(max(y)+min(y))/2])
print('endpoint',endpoint)
# Map midpoint:
endpoint_mapped = u(endpoint,kappa,e)
print('mapped endpoint', endpoint_mapped)
endpoint_mapped = Rotation.dot(endpoint_mapped)
mapped_e = grad_u(endpoint,kappa,e)
normal = compute_normal(endpoint,kappa,e)
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
reverse_normal = np.array([ (-1)*normal[0], (-1)*normal[1], (-1)*normal[2]])
ax.plot(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=1, # marker size
markerfacecolor='black', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=0.5, # marker edge width
linewidth=1,
zorder=5) # line width
# ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_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(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 1.5,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 5)
ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
reverse_normal[0],reverse_normal[1],reverse_normal[2],
mutation_scale=10,
lw = 1.5,
arrowstyle="-|>",
linestyle='-',fc='purple', alpha=0.75,
ec ='purple',
zorder = 5)
# second Endpoint
endpoint = np.array([max(x),(max(y)+min(y))/2])
print('endpoint',endpoint)
# Map midpoint:
endpoint_mapped = u(endpoint,kappa,e)
print('mapped endpoint', endpoint_mapped)
endpoint_mapped = Rotation.dot(endpoint_mapped)
mapped_e = grad_u(endpoint,kappa,e)
normal = compute_normal(endpoint,kappa,e)
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
reverse_normal = np.array([ (-1)*normal[0], (-1)*normal[1], (-1)*normal[2]])
ax.plot(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2], # data
marker='o', # each marker will be rendered as a circle
markersize=1, # marker size
markerfacecolor='black', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=0.5, # marker edge width
linewidth=1,
zorder=5) # line width
# ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_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(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 1.5,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 5)
ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
reverse_normal[0],reverse_normal[1],reverse_normal[2],
mutation_scale=10,
lw = 1.5,
arrowstyle="-|>",
linestyle='-',fc='purple', alpha=0.75,
ec ='purple',
zorder = 5)
# 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() /12
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /8
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /10
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /14
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /6
# 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)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
# ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-1.5, (mid_u2 + max_range)+1.5)
# # ax.autoscale(tight=True)
# ax.set_xlim((mid_u1 - max_range)-1, (mid_u1 + max_range)+1)
# ax.set_xlim((mid_u1 - max_range)-0.5, (mid_u1 + max_range)+0.5)
ax.set_xlim((mid_u1 - max_range)-2, (mid_u1 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+3)
# ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
##----- 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)
# ax.view_init(elev=25, azim=-30)
# ax.view_init(elev=18, azim=-30)
ax.view_init(elev=25, azim=-125)
# ax.view_init(elev=25, azim=150)
# ax.view_init(elev=25, azim=135)
# ax.view_init(elev=25, azim=125) #idx2
# ax.view_init(elev=25, azim=145)
# 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)
Figurename = r'1-ParFamMinimizer_idx' + str(idx)
# 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', dpi=300)
# 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 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)
################################################################################################################
################################################################################################################
################################################################################################################
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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
print('T:', T)
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
e_container = []
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 ]
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]
e_container.append(e)
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
G_container = np.array(G_container)
abar_container = np.array(abar_container)
e_container = np.array(e_container)
print('G_container', G_container)
print('G_container.shape', G_container.shape)
# idx_1 = np.where(alphas == np.pi/4)
idx_1 = np.where(np.round(alphas,2) == round(np.pi/3,2))
idx_2 = np.where(np.round(alphas,2) == 0.0)
idx_3 = np.where(np.round(alphas,2) == round(np.pi/4,2))
# idx_3 = np.where(alphas == 0)
print('Index idx_1:', idx_1)
print('Index idx_2:', idx_2)
print('Index idx_3:', idx_3)
print('Index idx_1[0][0]:', idx_1[0][0])
print('Index idx_2[0][0]:', idx_2[0][0])
print('Index idx_3[0][0]:', idx_3[0][0])
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('kappas:',kappas)
# print('alphas:',alphas)
print('min alpha:', min(alphas))
print('min kappa:', min(kappas))
print('G_container[idx_1[0][0]]', G_container[idx_1[0][0]])
print('G_container[idx_2[0][0]]', G_container[idx_2[0][0]])
print('G_container[idx_3[0][0]]', G_container[idx_3[0][0]])
print('e_container[idx_1[0][0]]', e_container[idx_1[0][0]])
print('e_container[idx_2[0][0]]', e_container[idx_2[0][0]])
print('e_container[idx_3[0][0]]', e_container[idx_3[0][0]])
###################################################
reflect = False
# reflect = True
idx = 1
if idx == 1 :
e = e_container[idx_1[0][0]]
kappa = kappas[idx_1[0][0]]
angle = alphas[idx_1[0][0]]
reflect = True
if idx == 2 :
e = e_container[idx_2[0][0]]
kappa = kappas[idx_2[0][0]]
angle = alphas[idx_2[0][0]]
if idx == 3 :
e = e_container[idx_3[0][0]]
kappa = kappas[idx_3[0][0]]
angle = alphas[idx_3[0][0]]
### SCALE ?
# kappa = kappa*2
print('kappa:',kappa)
print('angle:',angle)
###################################################
#### TEST apply reflection
#
# G_tmp = G_container[idx_1[0][0]]
#
# print('G_tmp', G_tmp)
#
# # Basis:
# G_1 = np.array([[1.0,0.0], [0.0,0.0]])
# G_2 = np.array([[0.0,0.0], [0.0,1.0]])
# G_3 = (1/np.sqrt(2))*np.array([[0.0,1.0], [1.0,0.0]])
# print('G_1', G_1)
# print('G_2', G_2)
# print('G_3', G_3)
#
# G = G_tmp[0] * G_1 + G_tmp[1]*G_2 + G_tmp[2]*G_3
# print('G:', G )
#
# T = np.array([[1.0 , -1.0] , [-1.0,1.0]])
#
# TG = np.multiply(T,G)
# print('TG', TG)
#
#
#
# v = np.array([np.sqrt(TG[0][0]),np.sqrt(TG[1][1]) ])
# print('v', v)
# print('norm(v):', np.linalg.norm(v))
# norm_v = np.linalg.norm(v)
#
# kappa = norm_v**2
#
# e = (1/norm_v)*v
# print('e:', e)
# print('kappa:', kappa)
if reflect == True:
reflected_e = np.array([e[0], -1*e[1]])
e = reflected_e # Correct?! Reflect e on x-Axis ??!
print('reflected_e:', reflected_e)
############################################################################################################################################
####################################################################### 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(-2,2,num_Points)
x = np.linspace(-3,3,num_Points)
x = np.linspace(-4,4,num_Points)
# 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)
y = np.linspace(-1/4,1/4,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 * 0.333
height = width / 1.618
height = width / 2.5
height = width
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)
###---- 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)
# 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 = 10, cstride = 10, facecolors=cm.brg(colorfunction), alpha=.8, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 5, cstride = 5, color='orange', alpha=.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color='blue', alpha=.8, zorder=4, shade=True)
# 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)
# Plot 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=5) # line width
#midpoint:
endpoint = np.array([min(x),(max(y)+min(y))/2])
print('endpoint',endpoint)
# Map midpoint:
endpoint_mapped = u(endpoint,kappa,e)
print('mapped endpoint', endpoint_mapped)
endpoint_mapped = Rotation.dot(endpoint_mapped)
mapped_e = grad_u(endpoint,kappa,e)
normal = compute_normal(endpoint,kappa,e)
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
# ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_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(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 1.5,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 5)
# 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]
# 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() /12
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /8
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /10
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /14
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /6
# 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)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-1.5, (mid_u2 + max_range)+1.5)
# ax.autoscale(tight=True)
ax.set_xlim((mid_u1 - max_range)-1, (mid_u1 + max_range)+1)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+3)
# ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
##----- 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)
# ax.view_init(elev=25, azim=-30)
ax.view_init(elev=18, azim=-30)
# 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)
Figurename = r'1-ParFamMinimizer_idx' + str(idx)
# 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 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)
################################################################################################################
################################################################################################################
################################################################################################################
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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
T = np.linspace(-sstar*(q12+2*q3)/(2*q2), sstar*(2*q2)/(q12+2*q3), num=N)
print('T:', T)
kappas = []
alphas = []
# G.append(float(s[0]))
G_container = []
abar_container = []
e_container = []
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 ]
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]
e_container.append(e)
kappa = abar_current[0]+abar_current[1]
alpha = math.atan2(e[1], e[0])
# print('angle current:', alpha)
kappas.append(kappa)
alphas.append(alpha)
G_container = np.array(G_container)
abar_container = np.array(abar_container)
e_container = np.array(e_container)
print('G_container', G_container)
print('G_container.shape', G_container.shape)
# idx_1 = np.where(alphas == np.pi/4)
idx_1 = np.where(np.round(alphas,2) == round(np.pi/3,2))
idx_2 = np.where(np.round(alphas,2) == 0.0)
idx_3 = np.where(np.round(alphas,2) == round(np.pi/4,2))
# idx_3 = np.where(alphas == 0)
print('Index idx_1:', idx_1)
print('Index idx_2:', idx_2)
print('Index idx_3:', idx_3)
print('Index idx_1[0][0]:', idx_1[0][0])
print('Index idx_2[0][0]:', idx_2[0][0])
print('Index idx_3[0][0]:', idx_3[0][0])
alphas = np.array(alphas)
kappas = np.array(kappas)
# print('kappas:',kappas)
# print('alphas:',alphas)
print('min alpha:', min(alphas))
print('min kappa:', min(kappas))
print('G_container[idx_1[0][0]]', G_container[idx_1[0][0]])
print('G_container[idx_2[0][0]]', G_container[idx_2[0][0]])
print('G_container[idx_3[0][0]]', G_container[idx_3[0][0]])
print('e_container[idx_1[0][0]]', e_container[idx_1[0][0]])
print('e_container[idx_2[0][0]]', e_container[idx_2[0][0]])
print('e_container[idx_3[0][0]]', e_container[idx_3[0][0]])
###################################################
reflect = False
# reflect = True
idx = 1
if idx == 1 :
e = e_container[idx_1[0][0]]
kappa = kappas[idx_1[0][0]]
angle = alphas[idx_1[0][0]]
reflect = True
if idx == 2 :
e = e_container[idx_2[0][0]]
kappa = kappas[idx_2[0][0]]
angle = alphas[idx_2[0][0]]
if idx == 3 :
e = e_container[idx_3[0][0]]
kappa = kappas[idx_3[0][0]]
angle = alphas[idx_3[0][0]]
### SCALE ?
# kappa = kappa*2
print('kappa:',kappa)
print('angle:',angle)
###################################################
#### TEST apply reflection
#
# G_tmp = G_container[idx_1[0][0]]
#
# print('G_tmp', G_tmp)
#
# # Basis:
# G_1 = np.array([[1.0,0.0], [0.0,0.0]])
# G_2 = np.array([[0.0,0.0], [0.0,1.0]])
# G_3 = (1/np.sqrt(2))*np.array([[0.0,1.0], [1.0,0.0]])
# print('G_1', G_1)
# print('G_2', G_2)
# print('G_3', G_3)
#
# G = G_tmp[0] * G_1 + G_tmp[1]*G_2 + G_tmp[2]*G_3
# print('G:', G )
#
# T = np.array([[1.0 , -1.0] , [-1.0,1.0]])
#
# TG = np.multiply(T,G)
# print('TG', TG)
#
#
#
# v = np.array([np.sqrt(TG[0][0]),np.sqrt(TG[1][1]) ])
# print('v', v)
# print('norm(v):', np.linalg.norm(v))
# norm_v = np.linalg.norm(v)
#
# kappa = norm_v**2
#
# e = (1/norm_v)*v
# print('e:', e)
# print('kappa:', kappa)
if reflect == True:
reflected_e = np.array([e[0], -1*e[1]])
e = reflected_e # Correct?! Reflect e on x-Axis ??!
print('reflected_e:', reflected_e)
############################################################################################################################################
####################################################################### 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(-2,2,num_Points)
x = np.linspace(-3,3,num_Points)
x = np.linspace(-4,4,num_Points)
# 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)
y = np.linspace(-1/4,1/4,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 * 0.333
height = width / 1.618
height = width / 2.5
height = width
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)
###---- 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)
# 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 = 10, cstride = 10, facecolors=cm.brg(colorfunction), alpha=.8, zorder=4)
ax.plot_surface(T[0], T[1], T[2], rstride = 5, cstride = 5, color='orange', alpha=.8, zorder=4)
# ax.plot_surface(T[0], T[1], T[2], rstride = 10, cstride = 10, color='blue', alpha=.8, zorder=4, shade=True)
# 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)
# Plot 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=5) # line width
#midpoint:
endpoint = np.array([min(x),(max(y)+min(y))/2])
print('endpoint',endpoint)
# Map midpoint:
endpoint_mapped = u(endpoint,kappa,e)
print('mapped endpoint', endpoint_mapped)
endpoint_mapped = Rotation.dot(endpoint_mapped)
mapped_e = grad_u(endpoint,kappa,e)
normal = compute_normal(endpoint,kappa,e)
mapped_e = Rotation.dot(mapped_e)
normal = Rotation.dot(normal)
# ax.arrow3D(endpoint_mapped[0],endpoint_mapped[1],endpoint_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(endpoint_mapped[0],endpoint_mapped[1],endpoint_mapped[2],
# normal[0],normal[1],normal[2],
# mutation_scale=15,
# lw = 1.5,
# arrowstyle="-|>",
# linestyle='dashed',fc='blue',
# ec ='blue',
# zorder = 5)
# 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]
# 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() /12
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /8
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /10
max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /14
# max_range = np.array([u1.max()-u1.min(), u2.max()-u2.min(), u3.max()-u3.min()]).max() /6
# 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)
ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
# ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-1.5, (mid_u2 + max_range)+1.5)
# # ax.autoscale(tight=True)
ax.set_xlim((mid_u1 - max_range)-1, (mid_u1 + max_range)+1)
ax.set_xlim((mid_u1 - max_range)-0.5, (mid_u1 + max_range)+0.5)
# ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+2)
ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
# ax.set_ylim((mid_u2 - max_range)-2, (mid_u2 + max_range)+3)
# ax.set_zlim((mid_u2 - max_range), (mid_u2 + max_range)+2)
##----- 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)
ax.view_init(elev=25, azim=-30)
# ax.view_init(elev=18, azim=-30)
# 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)
Figurename = r'1-ParFamMinimizer_idx' + str(idx)
# 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 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 mpl_toolkits.mplot3d.proj3d import proj_transform
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
# 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 evaluate(x,y):
# (abar[0,:]*abar[1,:])**0.5
return np.sqrt(x*y)
# 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 add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
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)
################################################################################################################
################################################################################################################
################################################################################################################
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('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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
scale_domain = 5
translate_startpoint = -5
# 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)
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 20
num_Points = 50
# 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)
range = 2
x_1 = np.linspace(0,range,num_Points)
y_1 = np.linspace(0,range,num_Points)
x_2 = np.linspace(-range,0,num_Points)
y_2 = np.linspace(-range,0,num_Points)
X_1,Y_1 = np.meshgrid(x_1,y_1)
X_2,Y_2 = np.meshgrid(x_2,y_2)
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)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1 = a1[np.where(a1>=0 and a2 >= 0)]
# tmp2 = a2[np.where(a1>=0 and a2 >= 0)]
# tmp1 = tmp1[np.where(a1 >= 0)]
# tmp2 = tmp2[np.where(a1 >= 0)]
# tmp1_pos = a1[np.where(a1*a2 >= 0)]
# tmp2_neg = a2[np.where(a1*a2 >= 0)]
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[0])
tmp1 = tmp1.reshape(-1,int(tmp1.shape[0]/2))
tmp2 = tmp2.reshape(-1,int(tmp2.shape[0]/2))
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[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)
# Z = (tmp2**2)/tmp1
Z = np.sqrt(tmp1*tmp2)
Z1 = np.sqrt(X_1*Y_1)
Z2 = np.sqrt(X_2*Y_2)
# Z_bar = np.sqrt(abar[0,:]*abar[1,:])
Z_bar = (abar[0,:]*abar[1,:])**0.5*abar
abar = abar.T
v1 = abar[0,:]
v2 = abar[1,:]
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
evaluateVec = np.vectorize(evaluate)
Z_bar = evaluateVec(abar[0,:],abar[1,:])
# Z = np.sqrt(np.multiply(tmp1,tmp2))
# Z = np.sqrt(a1*a2)
print('v1.shape', v1.shape)
print('v1', v1)
print('Z:', Z)
print('Z_bar:', Z_bar)
# 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=mpl.cm.viridis
# cmap=mpl.cm.inferno
# # # cmap=mpl.cm.Blues
# cmap=mpl.cm.magma
cmap=mpl.cm.cividis
# cmap=mpl.cm.gnuplot
# 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_surface(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.scatter(X_1,Y_1,Z1, s=0.2)
# ax.scatter(X_2,Y_2,Z2, s=0.2)
# ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
# linewidth=0, antialiased=False,alpha=1, zorder=5)
ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=1, zorder=5)
ax.plot_surface(X_2,Y_2,Z2 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=1, zorder=5)
# ax.plot(G[0,:],G[1,:],G[2,:])
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='yellow', linestyle='--')
# ax.scatter(abar[0,:],abar[1,:],Z_bar, color='purple', zorder=5)
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='royalblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='dodgerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='cornflowerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='darkorange', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='yellow', linestyle='--')
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=1, color='coral', linestyle='--', zorder=3)
line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=2)
# CS = ax.contour(X_1,Y_1,Z1, colors='k', levels=18, linewidths=(0.5,))
start = np.array([abar[0,499],abar[1,499],Z_bar[499]])
end = np.array([abar[0,500],abar[1,500],Z_bar[500]])
# plot starting point:
# ax.scatter(abar[0,0],abar[1,0],Z_bar[0], marker='^', s=30, color='black', zorder=5)
#
#
# ax.scatter(abar[0,500],abar[1,500],Z_bar[500], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(start[0],start[1],start[2], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(end[0],end[1],end[2], marker='^', s=30, color='purple', zorder=5)
print('start:', start)
print('end:', end)
dir = end-start
# ax.arrow()
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=10,
# arrowstyle="->",
# linestyle='dashed',fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# 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)
# Check proof:
# value at t = 0:
abar_zero= sstar*abar_tmp
# value_0 = [abar_zero[0], abar_zero[1] , (2*abar_zero[0]*abar_zero[1])**0.5 ]
value_0 = evaluate(abar_zero[0], abar_zero[1])
print('value_0', value_0)
# ax.scatter(value_0[0],value_0[1],value_0[2], marker='x', s=20, color='dodgerblue', zorder=5)
# ax.scatter(abar_zero[0], abar_zero[1],value_0, marker='o', s=30, color='dodgerblue', zorder=5)
## -----------------------------
# ax.scatter(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,Z, tmp2, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_trisurf(tmp1,tmp2, 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.plot(ax.get_xlim(),[0,0],'k--', linewidth=1)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=1)
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('1-ParameterFamily_G+.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()
def add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
# 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 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]
## ---------------
########################################
# 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)
##--------------
# 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)
print('sstar*abar:', sstar*abar)
# print('np.dot(sstar*abar):', np.dot(sstar*abar))
print('----------------------------')
N=1000;
# N=10;
scale_domain = 5
translate_startpoint = -1.8
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 = []
test = sstar*abar
abar_tmp = abar
for t in T :
abar_current = sstar*abar+t*abarperp;
# abar_current[abar_current < 1e-10] = 0 # Projection onto x-y-axis!!
print('abar_current', abar_current)
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])
# 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)
######################################
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
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)
# 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)
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.001
# 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 = 'royalblue'
# 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
## FILL
ax.fill_between([x.min(), 0-epsilon], y.min(), 0-epsilon, alpha=.25, color=fillcolor, zorder=4)#yellow
ax.fill_between([0+epsilon, x.max()], 0+epsilon, y.max(), alpha=.25, color=fillcolor, zorder=4)#yellow
ax.text(1,1, r"$\mathcal{G}^+_{\mathbf{R}^2}$", color='royalblue', size=15)
# ax.text(0.25,0.25, r"$\mathcal{S}$", color='darkorange', size=15)
# PLOT 1-PARAMETER FAMILY
print('abar:', abar)
print('abar[0,:]:', abar[0,:])
print('abar[1,:]:', abar[1,:])
line = ax.plot(abar[:,0],abar[:,1], linewidth=2, color='darkorange', linestyle='-', zorder=4)
# plt.arrow(x=1, y=0, dx=0.5, dy=0, )
# ax.arrow(1, 0, 0.5, 0, head_width=0.05, head_length=0.1, fc='k', ec='k', zorder=5)
# plt.arrow(1, 0, 0.8, 0, shape='full', lw=0, length_includes_head=True, head_width=.15, zorder=5, color='purple')
## PLOT ARROW:
# plt.arrow(1, 0, 0.5, 0, shape='full', lw=0, length_includes_head=True, head_width=.20, zorder=5, color='darkorange')
# plt.arrow(0, 1.8, 0, -0.8, shape='full', lw=0, length_includes_head=True, head_width=.20, zorder=5, color='darkorange')
# plt.arrow(0, 1.8, 0, -0.8, lw=0, head_width=.12, zorder=5, color='darkorange')
# plt.arrow(0, 2, 0, -0.5, shape='full', lw=0, length_includes_head=True, head_width=.12, zorder=5, color='darkorange')
# add_arrow(line, color='darkorange')
# 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, )
# print('test:',test)
# ax.scatter(test[0],test[1])
# ax.arrow(test[0],test[1],abarperp[0],abarperp[1])
# 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=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)
print('x.max()',x.max())
print('y.max()',y.max())
ax.set_xlim(x.min(),x.max())
ax.set_xlim(y.min(),y.max())
# 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+_Flat.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()
def add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
# 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 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]
## ---------------
########################################
# 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)
##--------------
# 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)
print('sstar*abar:', sstar*abar)
# print('np.dot(sstar*abar):', np.dot(sstar*abar))
print('----------------------------')
N=1000;
N=10;
scale_domain = 5
translate_startpoint = -1.8
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(-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 = []
test = sstar*abar
abar_tmp = abar
for t in T :
abar_current = sstar*abar+t*abarperp;
abar_current[abar_current < 1e-10] = 0 # Projection onto x-y-axis!!
print('abar_current', abar_current)
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])
# 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)
######################################
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
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
# # 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
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)
# 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)
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.001
# 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 = 'royalblue'
# 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
## FILL
ax.fill_between([x.min(), 0-epsilon], y.min(), 0-epsilon, alpha=.25, color=fillcolor, zorder=4)#yellow
ax.fill_between([0+epsilon, x.max()], 0+epsilon, y.max(), alpha=.25, color=fillcolor, zorder=4)#yellow
ax.text(1,1, r"$\mathcal{G}^+_{\mathbf{R}^2}$", color='royalblue', size=15)
# ax.text(0.25,0.25, r"$\mathcal{S}$", color='darkorange', size=15)
# PLOT 1-PARAMETER FAMILY
print('abar:', abar)
print('abar[0,:]:', abar[0,:])
print('abar[1,:]:', abar[1,:])
line = ax.plot(abar[:,0],abar[:,1], linewidth=1.5, color='darkorange', linestyle='-', zorder=4)
# plt.arrow(x=1, y=0, dx=0.5, dy=0, )
# ax.arrow(1, 0, 0.5, 0, head_width=0.05, head_length=0.1, fc='k', ec='k', zorder=5)
# plt.arrow(1, 0, 0.8, 0, shape='full', lw=0, length_includes_head=True, head_width=.15, zorder=5, color='purple')
## PLOT ARROW:
# plt.arrow(1, 0, 0.5, 0, shape='full', lw=0, length_includes_head=True, head_width=.20, zorder=5, color='darkorange')
# plt.arrow(0, 1.8, 0, -0.8, shape='full', lw=0, length_includes_head=True, head_width=.20, zorder=5, color='darkorange')
# plt.arrow(0, 1.8, 0, -0.8, lw=0, head_width=.12, zorder=5, color='darkorange')
# plt.arrow(0, 2, 0, -0.5, shape='full', lw=0, length_includes_head=True, head_width=.12, zorder=5, color='darkorange')
# add_arrow(line, color='darkorange')
# 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, )
# print('test:',test)
# ax.scatter(test[0],test[1])
# ax.arrow(test[0],test[1],abarperp[0],abarperp[1])
line_values= np.array(line_values)
ax.plot(line_values[:,0],line_values[:,1],'k--', linewidth=1,color='orange',alpha=0.5)
# 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=f_size ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=f_size ,labelpad=0, 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_ylim(-2,2)
# 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)
print('x.max()',x.max())
print('y.max()',y.max())
ax.set_xlim(x.min(),x.max())
ax.set_xlim(y.min(),y.max())
plt.subplots_adjust(bottom=0.15)
plt.subplots_adjust(left=0.2)
# 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+_Flat.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 mpl_toolkits.mplot3d.proj3d import proj_transform
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
# 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 evaluate(x,y):
# (abar[0,:]*abar[1,:])**0.5
return np.sqrt(x*y)
# 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 add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
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)
################################################################################################################
################################################################################################################
################################################################################################################
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('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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
scale_domain = 5
translate_startpoint = -5
# 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)
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 20
num_Points = 50
num_Points = 200
# 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)
range = 2
x_1 = np.linspace(0,range,num_Points)
y_1 = np.linspace(0,range,num_Points)
x_2 = np.linspace(-range,0,num_Points)
y_2 = np.linspace(-range,0,num_Points)
X_1,Y_1 = np.meshgrid(x_1,y_1)
X_2,Y_2 = np.meshgrid(x_2,y_2)
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)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1 = a1[np.where(a1>=0 and a2 >= 0)]
# tmp2 = a2[np.where(a1>=0 and a2 >= 0)]
# tmp1 = tmp1[np.where(a1 >= 0)]
# tmp2 = tmp2[np.where(a1 >= 0)]
# tmp1_pos = a1[np.where(a1*a2 >= 0)]
# tmp2_neg = a2[np.where(a1*a2 >= 0)]
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[0])
tmp1 = tmp1.reshape(-1,int(tmp1.shape[0]/2))
tmp2 = tmp2.reshape(-1,int(tmp2.shape[0]/2))
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[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)
# Z = (tmp2**2)/tmp1
Z = np.sqrt(tmp1*tmp2)
Z1 = np.sqrt(X_1*Y_1)
Z2 = np.sqrt(X_2*Y_2)
# Z_bar = np.sqrt(abar[0,:]*abar[1,:])
Z_bar = (abar[0,:]*abar[1,:])**0.5*abar
abar = abar.T
v1 = abar[0,:]
v2 = abar[1,:]
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
evaluateVec = np.vectorize(evaluate)
Z_bar = evaluateVec(abar[0,:],abar[1,:])
# Z = np.sqrt(np.multiply(tmp1,tmp2))
# Z = np.sqrt(a1*a2)
print('v1.shape', v1.shape)
print('v1', v1)
print('Z:', Z)
print('Z_bar:', Z_bar)
# 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=mpl.cm.viridis
# cmap=mpl.cm.inferno
cmap=mpl.cm.Blues
# cmap=mpl.cm.magma
# cmap=mpl.cm.cividis
# cmap=mpl.cm.gnuplot
# cmap=mpl.cm.gnuplot
cmap = mpl.colors.ListedColormap(["royalblue"], name='from_list', N=None)
# m = cm.ScalarMappable(norm=norm, cmap=cmap)
# m = cm.ScalarMappable(cmap=cmap)
# 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
line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=2)
# CS = ax.contour(X_1,Y_1,Z1, colors='k', levels=18, linewidths=(0.5,))
start = np.array([abar[0,499],abar[1,499],Z_bar[499]])
end = np.array([abar[0,500],abar[1,500],Z_bar[500]])
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.scatter(X_1,Y_1,Z1, s=0.2)
# ax.scatter(X_2,Y_2,Z2, s=0.2)
# X = np.concatenate((X_1, X_2), axis=0)
# Y = np.concatenate((Y_1, Y_2), axis=0)
# Z = np.concatenate((Z1, Z2), axis=0)
# ax.plot_surface(X,Y,Z)
ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.75, zorder=5)
ax.plot_surface(X_2,Y_2,Z2 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.75, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , facecolor = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , facecolor = 'lightblue', edgecolor='none', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , #color='C0',
# rstride=1, cstride=1,linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , #color='C0',
# rstride=1, cstride=1,linewidth=0, alpha=0.8, zorder=5, shade=True)
# ax.plot_surface(X_2,Y_2,Z2)
# X_2 = X_2.reshape(-1,1).flatten()
# Y_2 = Y_2.reshape(-1,1).flatten()
# Z2 = Z2.reshape(-1,1).flatten()
# #
# ax.plot_trisurf(X_2,Y_2,Z2, color='blue' )
#
#
# X_1 = X_1.reshape(-1,1).flatten()
# Y_1 = Y_1.reshape(-1,1).flatten()
# Z1 = Z1.reshape(-1,1).flatten()
# ax.plot_trisurf(X_1,Y_1,Z1 , color='blue')
# ax.plot_surface(X_1,Y_1,Z1 , cmap=cmap,
# linewidth=0, antialiased=False,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , cmap=cmap,
# linewidth=0, antialiased=True,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , color = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot(G[0,:],G[1,:],G[2,:])
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='yellow', linestyle='--')
# ax.scatter(abar[0,:],abar[1,:],Z_bar, color='purple', zorder=5)
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='royalblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='dodgerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='cornflowerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='darkorange', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='yellow', linestyle='--')
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=1, color='coral', linestyle='--', zorder=3)
# plot starting point:
# ax.scatter(abar[0,0],abar[1,0],Z_bar[0], marker='^', s=30, color='black', zorder=5)
#
#
# ax.scatter(abar[0,500],abar[1,500],Z_bar[500], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(start[0],start[1],start[2], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(end[0],end[1],end[2], marker='^', s=30, color='purple', zorder=5)
print('start:', start)
print('end:', end)
dir = end-start
# ax.arrow()
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=10,
# arrowstyle="->",
# linestyle='dashed',fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# 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)
# Check proof:
# value at t = 0:
abar_zero= sstar*abar_tmp
# value_0 = [abar_zero[0], abar_zero[1] , (2*abar_zero[0]*abar_zero[1])**0.5 ]
value_0 = evaluate(abar_zero[0], abar_zero[1])
print('value_0', value_0)
# ax.scatter(value_0[0],value_0[1],value_0[2], marker='x', s=20, color='dodgerblue', zorder=5)
# ax.scatter(abar_zero[0], abar_zero[1],value_0, marker='o', s=30, color='dodgerblue', zorder=5)
## -----------------------------
# ax.scatter(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,Z, tmp2, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_trisurf(tmp1,tmp2, 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.plot(ax.get_xlim(),[0,0],'k--', linewidth=1)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=1)
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('1-ParameterFamily_G+.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 mpl_toolkits.mplot3d.proj3d import proj_transform
from mpl_toolkits.mplot3d import proj3d
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
import mayavi.mlab as mlab
from mayavi.api import OffScreenEngine
mlab.options.offscreen = True
from chart_studio import plotly
import plotly.graph_objs as go
# 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 evaluate(x,y):
# (abar[0,:]*abar[1,:])**0.5
return np.sqrt(x*y)
# 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 add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
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, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
self._verts3d = xs, ys, zs
def draw(self, renderer):
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
FancyArrowPatch.draw(self, 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)
################################################################################################################
################################################################################################################
################################################################################################################
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('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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
# scale_domain = 5
# translate_startpoint = -5
scale_domain = 5
translate_startpoint = -1.8
# 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)
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 20
num_Points = 50
num_Points = 200
# 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)
range = 2
x_1 = np.linspace(0,range,num_Points)
y_1 = np.linspace(0,range,num_Points)
x_2 = np.linspace(-range,0,num_Points)
y_2 = np.linspace(-range,0,num_Points)
X_1,Y_1 = np.meshgrid(x_1,y_1)
X_2,Y_2 = np.meshgrid(x_2,y_2)
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)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1 = a1[np.where(a1>=0 and a2 >= 0)]
# tmp2 = a2[np.where(a1>=0 and a2 >= 0)]
# tmp1 = tmp1[np.where(a1 >= 0)]
# tmp2 = tmp2[np.where(a1 >= 0)]
# tmp1_pos = a1[np.where(a1*a2 >= 0)]
# tmp2_neg = a2[np.where(a1*a2 >= 0)]
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[0])
tmp1 = tmp1.reshape(-1,int(tmp1.shape[0]/2))
tmp2 = tmp2.reshape(-1,int(tmp2.shape[0]/2))
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[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)
# Z = (tmp2**2)/tmp1
Z = np.sqrt(tmp1*tmp2)
Z1 = np.sqrt(X_1*Y_1)
Z2 = np.sqrt(X_2*Y_2)
# Z_bar = np.sqrt(abar[0,:]*abar[1,:])
Z_bar = (abar[0,:]*abar[1,:])**0.5*abar
abar = abar.T
v1 = abar[0,:]
v2 = abar[1,:]
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
evaluateVec = np.vectorize(evaluate)
Z_bar = evaluateVec(abar[0,:],abar[1,:])
# Z = np.sqrt(np.multiply(tmp1,tmp2))
# Z = np.sqrt(a1*a2)
print('v1.shape', v1.shape)
print('v1', v1)
print('Z:', Z)
print('Z_bar:', Z_bar)
# 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
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)
ax.grid(True,which='major',axis='xy',alpha=0.3)
# ax.grid(False,which='major',alpha=0.3)
# Hide grid lines
# ax.grid(False)
# 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=mpl.cm.viridis
# cmap=mpl.cm.inferno
cmap=mpl.cm.Blues
# cmap=mpl.cm.magma
# cmap=mpl.cm.cividis
# cmap=mpl.cm.gnuplot
# cmap=mpl.cm.gnuplot
cmap = mpl.colors.ListedColormap(["royalblue"], name='from_list', N=None)
# m = cm.ScalarMappable(norm=norm, cmap=cmap)
# m = cm.ScalarMappable(cmap=cmap)
# 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
print('abar', abar)
print('abar.shape',abar.shape)
line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=1)
# CS = ax.contour(X_1,Y_1,Z1, colors='k', levels=18, linewidths=(0.5,))
start = np.array([abar[0,499],abar[1,499],Z_bar[499]])
end = np.array([abar[0,500],abar[1,500],Z_bar[500]])
# idx = np.where(np.round(Z_bar,3) == np.round( 0.03581463,3) )
idx = np.where(np.round(Z_bar,3) == np.round( 0.02823972,3) )
print('idx[0][0]', idx[0][0])
# abar_1 = abar[0,0:idx[0][0]]
# abar_2 = abar[1,0:idx[0][0]]
line = ax.plot(abar[0,idx[0][0]:-1],abar[1,idx[0][0]:-1],Z_bar[idx[0][0]:-1], linewidth=2, color='coral', zorder=5)
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.scatter(X_1,Y_1,Z1, s=0.2)
# ax.scatter(X_2,Y_2,Z2, s=0.2)
# X = np.concatenate((X_1, X_2), axis=0)
# Y = np.concatenate((Y_1, Y_2), axis=0)
# Z = np.concatenate((Z1, Z2), axis=0)
# ax.plot_surface(X,Y,Z)
ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
ax.plot_surface(X_2,Y_2,Z2 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , facecolor = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , facecolor = 'lightblue', edgecolor='none', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , #color='C0',
# rstride=1, cstride=1,linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , #color='C0',
# rstride=1, cstride=1,linewidth=0, alpha=0.8, zorder=5, shade=True)
# ax.plot_surface(X_2,Y_2,Z2)
# X_2 = X_2.reshape(-1,1).flatten()
# Y_2 = Y_2.reshape(-1,1).flatten()
# Z2 = Z2.reshape(-1,1).flatten()
#
# ax.plot_trisurf(X_2,Y_2,Z2, color='blue' )
# X_1 = X_1.reshape(-1,1).flatten()
# Y_1 = Y_1.reshape(-1,1).flatten()
# Z1 = Z1.reshape(-1,1).flatten()
# ax.plot_trisurf(X_1,Y_1,Z1 , color='blue')
### MAYAVI TEST
# mlab.figure(bgcolor=(1.0, 1.0, 1.0), size=(1000,1000))
# mlab.view(azimuth=90, elevation=125)
# mlab.view(azimuth=100, elevation=115)
# axes = mlab.axes(color=(0, 0, 0), nb_labels=5)
# mlab.orientation_axes()
# mlab.mesh(X_1, Y_1,Z1, color=(0,0,1) , transparent=True )
# mlab.plot3d(abar[0,:],abar[1,:],Z_bar, line_width=1)
# mlab.mesh(X_2, Y_2,Z2)
# mlab.savefig("./example.png")
### --------------------------------------------
# ax.plot_surface(X_1,Y_1,Z1 , cmap=cmap,
# linewidth=0, antialiased=False,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , cmap=cmap,
# linewidth=0, antialiased=True,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , color = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot(G[0,:],G[1,:],G[2,:])
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='yellow', linestyle='--')
# ax.scatter(abar[0,:],abar[1,:],Z_bar, color='purple', zorder=5)
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='royalblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='dodgerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='cornflowerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='darkorange', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='yellow', linestyle='--')
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=1, color='coral', linestyle='--', zorder=3)
# plot starting point:
# ax.scatter(abar[0,0],abar[1,0],Z_bar[0], marker='^', s=30, color='black', zorder=5)
#
#
# ax.scatter(abar[0,500],abar[1,500],Z_bar[500], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(start[0],start[1],start[2], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(end[0],end[1],end[2], marker='^', s=30, color='purple', zorder=5)
# define origin
o = np.array([0,0,0])
start = np.array([1,0,0])
end = np.array([2.5,0,0])
print('start:', start)
print('end:', end)
dir = end-start
print('dir:', dir)
# ax.arrow()
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=10,
# arrowstyle="->",
# linestyle='dashed',fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# 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)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
arrow_prop_dict = dict(mutation_scale=20, arrowstyle='-|>', color='k', shrinkA=0, shrinkB=0)
# style = ArrowStyle('Fancy', head_length=1, head_width=1.5, tail_width=0.5)
# ADD ARROW:
# a = Arrow3D([start[0], end[0]], [start[1], end[1]], [start[2], end[2]], mutation_scale=15, arrowstyle='-|>', color='darkorange')
# ax.add_artist(a)
## ADD Annotation
ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=12)
# ax.text(0.5, 0.5, "Test")
# ax.text(9, 0, 0, "red", color='red')
### ---- Check proof:
# value at t = 0:
abar_zero= sstar*abar_tmp
# value_0 = [abar_zero[0], abar_zero[1] , (2*abar_zero[0]*abar_zero[1])**0.5 ]
value_0 = evaluate(abar_zero[0], abar_zero[1])
print('value_0', value_0)
# ax.scatter(value_0[0],value_0[1],value_0[2], marker='x', s=20, color='dodgerblue', zorder=5)
# ax.scatter(abar_zero[0], abar_zero[1],value_0, marker='o', s=30, color='dodgerblue', zorder=5)
## -----------------------------
# ax.scatter(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,Z, tmp2, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_trisurf(tmp1,tmp2, 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 AXIS:
# ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
# ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=1 ,zorder=5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=1)
ax.set_xlabel(r"$a_1$", fontsize=10 ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=10 ,labelpad=0)
# ax.get_xaxis().set_visible(False)
# ax = plt.gca(projection="3d")
# ax._axis3don = False
ZL = ax.get_zgridlines()
# 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('1-ParameterFamily_G+.pdf')
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 mpl_toolkits.mplot3d.proj3d import proj_transform
from mpl_toolkits.mplot3d import proj3d
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
import mayavi.mlab as mlab
from mayavi.api import OffScreenEngine
mlab.options.offscreen = True
from chart_studio import plotly
import plotly.graph_objs as go
# 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 evaluate(x,y):
# (abar[0,:]*abar[1,:])**0.5
return np.sqrt(x*y)
# 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 add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
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, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
self._verts3d = xs, ys, zs
def draw(self, renderer):
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
FancyArrowPatch.draw(self, 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)
################################################################################################################
################################################################################################################
################################################################################################################
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('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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
# scale_domain = 5
# translate_startpoint = -5
# scale_domain = 5
# translate_startpoint = -1.8
scale_domain = 5
translate_startpoint = -1.8
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;
# 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)
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 20
num_Points = 50
num_Points = 200
# 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)
range = 2
x_1 = np.linspace(0,range,num_Points)
y_1 = np.linspace(0,range,num_Points)
x_2 = np.linspace(-range,0,num_Points)
y_2 = np.linspace(-range,0,num_Points)
X_1,Y_1 = np.meshgrid(x_1,y_1)
X_2,Y_2 = np.meshgrid(x_2,y_2)
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)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1 = a1[np.where(a1>=0 and a2 >= 0)]
# tmp2 = a2[np.where(a1>=0 and a2 >= 0)]
# tmp1 = tmp1[np.where(a1 >= 0)]
# tmp2 = tmp2[np.where(a1 >= 0)]
# tmp1_pos = a1[np.where(a1*a2 >= 0)]
# tmp2_neg = a2[np.where(a1*a2 >= 0)]
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[0])
tmp1 = tmp1.reshape(-1,int(tmp1.shape[0]/2))
tmp2 = tmp2.reshape(-1,int(tmp2.shape[0]/2))
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[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)
# Z = (tmp2**2)/tmp1
Z = np.sqrt(tmp1*tmp2)
Z1 = np.sqrt(X_1*Y_1)
Z2 = np.sqrt(X_2*Y_2)
# Z_bar = np.sqrt(abar[0,:]*abar[1,:])
Z_bar = (abar[0,:]*abar[1,:])**0.5*abar
abar = abar.T
v1 = abar[0,:]
v2 = abar[1,:]
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
evaluateVec = np.vectorize(evaluate)
Z_bar = evaluateVec(abar[0,:],abar[1,:])
# Z = np.sqrt(np.multiply(tmp1,tmp2))
# Z = np.sqrt(a1*a2)
print('v1.shape', v1.shape)
print('v1', v1)
print('Z:', Z)
print('Z_bar:', Z_bar)
# 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
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)
ax.grid(True,which='major',axis='xy',alpha=0.3)
# ax.grid(False,which='major',alpha=0.3)
# Hide grid lines
# ax.grid(False)
# 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=mpl.cm.viridis
# cmap=mpl.cm.inferno
cmap=mpl.cm.Blues
# cmap=mpl.cm.magma
# cmap=mpl.cm.cividis
# cmap=mpl.cm.gnuplot
# cmap=mpl.cm.gnuplot
cmap = mpl.colors.ListedColormap(["royalblue"], name='from_list', N=None)
# m = cm.ScalarMappable(norm=norm, cmap=cmap)
# m = cm.ScalarMappable(cmap=cmap)
# 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
#### LINE SEGMENTS :
line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=5)
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=1)
# print('abar', abar)
# print('abar.shape',abar.shape)
# start = np.array([abar[0,499],abar[1,499],Z_bar[499]])
# end = np.array([abar[0,500],abar[1,500],Z_bar[500]])
# idx = np.where(np.round(Z_bar,3) == np.round( 0.02823972,3) )
# print('idx[0][0]', idx[0][0])
# line = ax.plot(abar[0,idx[0][0]:-1],abar[1,idx[0][0]:-1],Z_bar[idx[0][0]:-1], linewidth=2, color='coral', zorder=5)
### -----------------------------------
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.scatter(X_1,Y_1,Z1, s=0.2)
# ax.scatter(X_2,Y_2,Z2, s=0.2)
# X = np.concatenate((X_1, X_2), axis=0)
# Y = np.concatenate((Y_1, Y_2), axis=0)
# Z = np.concatenate((Z1, Z2), axis=0)
# ax.plot_surface(X,Y,Z)
ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
ax.plot_surface(X_2,Y_2,Z2 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , facecolor = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , facecolor = 'lightblue', edgecolor='none', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , #color='C0',
# rstride=1, cstride=1,linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , #color='C0',
# rstride=1, cstride=1,linewidth=0, alpha=0.8, zorder=5, shade=True)
# ax.plot_surface(X_2,Y_2,Z2)
# X_2 = X_2.reshape(-1,1).flatten()
# Y_2 = Y_2.reshape(-1,1).flatten()
# Z2 = Z2.reshape(-1,1).flatten()
#
# ax.plot_trisurf(X_2,Y_2,Z2, color='blue' )
# X_1 = X_1.reshape(-1,1).flatten()
# Y_1 = Y_1.reshape(-1,1).flatten()
# Z1 = Z1.reshape(-1,1).flatten()
# ax.plot_trisurf(X_1,Y_1,Z1 , color='blue')
### MAYAVI TEST
# mlab.figure(bgcolor=(1.0, 1.0, 1.0), size=(1000,1000))
# mlab.view(azimuth=90, elevation=125)
# mlab.view(azimuth=100, elevation=115)
# axes = mlab.axes(color=(0, 0, 0), nb_labels=5)
# mlab.orientation_axes()
# mlab.mesh(X_1, Y_1,Z1, color=(0,0,1) , transparent=True )
# mlab.plot3d(abar[0,:],abar[1,:],Z_bar, line_width=1)
# mlab.mesh(X_2, Y_2,Z2)
# mlab.savefig("./example.png")
### --------------------------------------------
# ax.plot_surface(X_1,Y_1,Z1 , cmap=cmap,
# linewidth=0, antialiased=False,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , cmap=cmap,
# linewidth=0, antialiased=True,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , color = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot(G[0,:],G[1,:],G[2,:])
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='yellow', linestyle='--')
# ax.scatter(abar[0,:],abar[1,:],Z_bar, color='purple', zorder=5)
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='royalblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='dodgerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='cornflowerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='darkorange', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='yellow', linestyle='--')
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=1, color='coral', linestyle='--', zorder=3)
# plot starting point:
# ax.scatter(abar[0,0],abar[1,0],Z_bar[0], marker='^', s=30, color='black', zorder=5)
#
#
# ax.scatter(abar[0,500],abar[1,500],Z_bar[500], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(start[0],start[1],start[2], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(end[0],end[1],end[2], marker='^', s=30, color='purple', zorder=5)
# define origin
o = np.array([0,0,0])
start = np.array([1,0,0])
end = np.array([2.5,0,0])
print('start:', start)
print('end:', end)
dir = end-start
print('dir:', dir)
# ax.arrow()
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=10,
# arrowstyle="->",
# linestyle='dashed',fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# 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)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
arrow_prop_dict = dict(mutation_scale=20, arrowstyle='-|>', color='k', shrinkA=0, shrinkB=0)
# style = ArrowStyle('Fancy', head_length=1, head_width=1.5, tail_width=0.5)
# ADD ARROW:
# a = Arrow3D([start[0], end[0]], [start[1], end[1]], [start[2], end[2]], mutation_scale=15, arrowstyle='-|>', color='darkorange')
# ax.add_artist(a)
## ADD Annotation
# ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=12)
ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=15)
# ax.text(0.5, 0.5, "Test")
# ax.text(9, 0, 0, "red", color='red')
### ---- Check proof:
# value at t = 0:
abar_zero= sstar*abar_tmp
# value_0 = [abar_zero[0], abar_zero[1] , (2*abar_zero[0]*abar_zero[1])**0.5 ]
value_0 = evaluate(abar_zero[0], abar_zero[1])
print('value_0', value_0)
# ax.scatter(value_0[0],value_0[1],value_0[2], marker='x', s=20, color='dodgerblue', zorder=5)
# ax.scatter(abar_zero[0], abar_zero[1],value_0, marker='o', s=30, color='dodgerblue', zorder=5)
## -----------------------------
# ax.scatter(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,Z, tmp2, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_trisurf(tmp1,tmp2, 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 AXIS:
# ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
# ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=1 ,zorder=5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=1)
# Plot 1-Parameter Line
line_values= np.array(line_values)
ax.plot(line_values[:,0],line_values[:,1],'k--', linewidth=1,color='orange',alpha=0.8)
ax.set_xlabel(r"$a_1$", fontsize=10 ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=10 ,labelpad=0)
plt.subplots_adjust(left=0.0)
plt.subplots_adjust(bottom=0.25)
# ax.get_xaxis().set_visible(False)
# ax = plt.gca(projection="3d")
# ax._axis3don = False
ZL = ax.get_zgridlines()
# 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('1-ParameterFamily_G+.pdf')
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
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 mpl_toolkits.mplot3d.proj3d import proj_transform
from mpl_toolkits.mplot3d import proj3d
# from mpl_toolkits.mplot3d.axes3d import Axes3D
from matplotlib.text import Annotation
from matplotlib.patches import FancyArrowPatch
import mayavi.mlab as mlab
from mayavi.api import OffScreenEngine
mlab.options.offscreen = True
from chart_studio import plotly
import plotly.graph_objs as go
# 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 evaluate(x,y):
# (abar[0,:]*abar[1,:])**0.5
return np.sqrt(x*y)
# 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 add_arrow(line, position=None, direction='right', size=15, color=None):
"""
add an arrow to a line.
line: Line2D object
position: x-position of the arrow. If None, mean of xdata is taken
direction: 'left' or 'right'
size: size of the arrow in fontsize points
color: if None, line color is taken.
"""
if color is None:
color = line.get_color()
xdata = line.get_xdata()
ydata = line.get_ydata()
if position is None:
position = xdata.mean()
# find closest index
start_ind = np.argmin(np.absolute(xdata - position))
if direction == 'right':
end_ind = start_ind + 1
else:
end_ind = start_ind - 1
line.axes.annotate('',
xytext=(xdata[start_ind], ydata[start_ind]),
xy=(xdata[end_ind], ydata[end_ind]),
arrowprops=dict(arrowstyle="->", color=color),
size=size
)
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, xs, ys, zs, *args, **kwargs):
FancyArrowPatch.__init__(self, (0,0), (0,0), *args, **kwargs)
self._verts3d = xs, ys, zs
def draw(self, renderer):
xs3d, ys3d, zs3d = self._verts3d
xs, ys, zs = proj3d.proj_transform(xs3d, ys3d, zs3d, renderer.M)
self.set_positions((xs[0],ys[0]),(xs[1],ys[1]))
FancyArrowPatch.draw(self, 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)
################################################################################################################
################################################################################################################
################################################################################################################
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('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)
print('----------------------------')
# ----------------------------------------------------------------
N=1000;
# scale_domain = 5
# translate_startpoint = -5
# scale_domain = 5
# translate_startpoint = -1.8
scale_domain = 5
translate_startpoint = -1.8
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;
# 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)
print('q1 = ', q1)
print('q2 = ', q2)
print('q3 = ', q3)
print('q12 = ', q12)
print('b1 = ', b1)
print('b2 = ', b2)
num_Points = 20
num_Points = 50
num_Points = 200
# 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)
range = 2
x_1 = np.linspace(0,range,num_Points)
y_1 = np.linspace(0,range,num_Points)
x_2 = np.linspace(-range,0,num_Points)
y_2 = np.linspace(-range,0,num_Points)
X_1,Y_1 = np.meshgrid(x_1,y_1)
X_2,Y_2 = np.meshgrid(x_2,y_2)
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)]
# tmp1 = a1[a1*a2 >= 0]
# tmp2 = a2[a1*a2 >= 0]
# tmp1 = a1[np.where(a1>=0 and a2 >= 0)]
# tmp2 = a2[np.where(a1>=0 and a2 >= 0)]
# tmp1 = tmp1[np.where(a1 >= 0)]
# tmp2 = tmp2[np.where(a1 >= 0)]
# tmp1_pos = a1[np.where(a1*a2 >= 0)]
# tmp2_neg = a2[np.where(a1*a2 >= 0)]
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[0])
tmp1 = tmp1.reshape(-1,int(tmp1.shape[0]/2))
tmp2 = tmp2.reshape(-1,int(tmp2.shape[0]/2))
print('tmp1.shape',tmp1.shape)
print('tmp1.shape[0]',tmp1.shape[0])
print('tmp2.shape',tmp2.shape)
print('tmp2.shape[0]',tmp2.shape[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)
# Z = (tmp2**2)/tmp1
Z = np.sqrt(tmp1*tmp2)
Z1 = np.sqrt(X_1*Y_1)
Z2 = np.sqrt(X_2*Y_2)
# Z_bar = np.sqrt(abar[0,:]*abar[1,:])
Z_bar = (abar[0,:]*abar[1,:])**0.5*abar
abar = abar.T
v1 = abar[0,:]
v2 = abar[1,:]
# print('a1:', a1)
# print('a2:',a2 )
# print('a1.shape', a1.shape)
evaluateVec = np.vectorize(evaluate)
Z_bar = evaluateVec(abar[0,:],abar[1,:])
# Z = np.sqrt(np.multiply(tmp1,tmp2))
# Z = np.sqrt(a1*a2)
print('v1.shape', v1.shape)
print('v1', v1)
print('Z:', Z)
print('Z_bar:', Z_bar)
# 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
mpl.rcParams["font.size"] =10
width = 6.28 *0.5
# 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)
ax.grid(True,which='major',axis='xy',alpha=0.3)
# ax.grid(False,which='major',alpha=0.3)
# Hide grid lines
# ax.grid(False)
# 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=mpl.cm.viridis
# cmap=mpl.cm.inferno
cmap=mpl.cm.Blues
# cmap=mpl.cm.magma
# cmap=mpl.cm.cividis
# cmap=mpl.cm.gnuplot
# cmap=mpl.cm.gnuplot
cmap = mpl.colors.ListedColormap(["royalblue"], name='from_list', N=None)
# m = cm.ScalarMappable(norm=norm, cmap=cmap)
# m = cm.ScalarMappable(cmap=cmap)
# 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
#### LINE SEGMENTS :
line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=5)
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='coral', zorder=1)
# print('abar', abar)
# print('abar.shape',abar.shape)
# start = np.array([abar[0,499],abar[1,499],Z_bar[499]])
# end = np.array([abar[0,500],abar[1,500],Z_bar[500]])
# idx = np.where(np.round(Z_bar,3) == np.round( 0.02823972,3) )
# print('idx[0][0]', idx[0][0])
# line = ax.plot(abar[0,idx[0][0]:-1],abar[1,idx[0][0]:-1],Z_bar[idx[0][0]:-1], linewidth=2, color='coral', zorder=5)
### -----------------------------------
# ax.plot_surface(a1,a2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.scatter(X_1,Y_1,Z1, s=0.2)
# ax.scatter(X_2,Y_2,Z2, s=0.2)
# X = np.concatenate((X_1, X_2), axis=0)
# Y = np.concatenate((Y_1, Y_2), axis=0)
# Z = np.concatenate((Z1, Z2), axis=0)
# ax.plot_surface(X,Y,Z)
ax.plot_surface(X_1,Y_1,Z1 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
ax.plot_surface(X_2,Y_2,Z2 ,cmap=cmap,
linewidth=0, antialiased=True,alpha=.35, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , facecolor = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , facecolor = 'lightblue', edgecolor='none', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_1,Y_1,Z1 , #color='C0',
# rstride=1, cstride=1,linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , #color='C0',
# rstride=1, cstride=1,linewidth=0, alpha=0.8, zorder=5, shade=True)
# ax.plot_surface(X_2,Y_2,Z2)
# X_2 = X_2.reshape(-1,1).flatten()
# Y_2 = Y_2.reshape(-1,1).flatten()
# Z2 = Z2.reshape(-1,1).flatten()
#
# ax.plot_trisurf(X_2,Y_2,Z2, color='blue' )
# X_1 = X_1.reshape(-1,1).flatten()
# Y_1 = Y_1.reshape(-1,1).flatten()
# Z1 = Z1.reshape(-1,1).flatten()
# ax.plot_trisurf(X_1,Y_1,Z1 , color='blue')
### MAYAVI TEST
# mlab.figure(bgcolor=(1.0, 1.0, 1.0), size=(1000,1000))
# mlab.view(azimuth=90, elevation=125)
# mlab.view(azimuth=100, elevation=115)
# axes = mlab.axes(color=(0, 0, 0), nb_labels=5)
# mlab.orientation_axes()
# mlab.mesh(X_1, Y_1,Z1, color=(0,0,1) , transparent=True )
# mlab.plot3d(abar[0,:],abar[1,:],Z_bar, line_width=1)
# mlab.mesh(X_2, Y_2,Z2)
# mlab.savefig("./example.png")
### --------------------------------------------
# ax.plot_surface(X_1,Y_1,Z1 , cmap=cmap,
# linewidth=0, antialiased=False,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , cmap=cmap,
# linewidth=0, antialiased=True,alpha=1, zorder=5)
# ax.plot_surface(X_2,Y_2,Z2 , color = 'lightblue', #cmap=cmap,
# linewidth=0, antialiased=True, alpha=1, zorder=5)
# ax.plot(G[0,:],G[1,:],G[2,:])
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='yellow', linestyle='--')
# ax.scatter(abar[0,:],abar[1,:],Z_bar, color='purple', zorder=5)
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=2, color='royalblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='dodgerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='cornflowerblue', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='darkorange', linestyle='--')
# ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=3, color='yellow', linestyle='--')
# line = ax.plot(abar[0,:],abar[1,:],Z_bar, linewidth=1, color='coral', linestyle='--', zorder=3)
# plot starting point:
# ax.scatter(abar[0,0],abar[1,0],Z_bar[0], marker='^', s=30, color='black', zorder=5)
#
#
# ax.scatter(abar[0,500],abar[1,500],Z_bar[500], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(start[0],start[1],start[2], marker='^', s=30, color='purple', zorder=5)
# ax.scatter(end[0],end[1],end[2], marker='^', s=30, color='purple', zorder=5)
# define origin
o = np.array([0,0,0])
start = np.array([1,0,0])
end = np.array([2.5,0,0])
print('start:', start)
print('end:', end)
dir = end-start
print('dir:', dir)
# ax.arrow()
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=10,
# arrowstyle="->",
# linestyle='dashed',fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# 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)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
# ax.arrow3D(start[0],start[1],start[2],
# dir[0],dir[1],dir[2],
# mutation_scale=20,
# arrowstyle="->",
# fc='coral',
# lw = 1,
# ec ='coral',
# zorder=3)
arrow_prop_dict = dict(mutation_scale=20, arrowstyle='-|>', color='k', shrinkA=0, shrinkB=0)
# style = ArrowStyle('Fancy', head_length=1, head_width=1.5, tail_width=0.5)
# ADD ARROW:
# a = Arrow3D([start[0], end[0]], [start[1], end[1]], [start[2], end[2]], mutation_scale=15, arrowstyle='-|>', color='darkorange')
# ax.add_artist(a)
## ADD Annotation
# ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=12)
# ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=15)
ax.text(0, 0, 1.5, r"$\mathcal G^+$", color='royalblue', size=13)
# ax.text(0.5, 0.5, "Test")
# ax.text(9, 0, 0, "red", color='red')
### ---- Check proof:
# value at t = 0:
abar_zero= sstar*abar_tmp
# value_0 = [abar_zero[0], abar_zero[1] , (2*abar_zero[0]*abar_zero[1])**0.5 ]
value_0 = evaluate(abar_zero[0], abar_zero[1])
print('value_0', value_0)
# ax.scatter(value_0[0],value_0[1],value_0[2], marker='x', s=20, color='dodgerblue', zorder=5)
# ax.scatter(abar_zero[0], abar_zero[1],value_0, marker='o', s=30, color='dodgerblue', zorder=5)
## -----------------------------
# ax.scatter(tmp1,tmp2, Z, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_surface(tmp1,Z, tmp2, cmap=cm.coolwarm,
# linewidth=0, antialiased=False)
# ax.plot_trisurf(tmp1,tmp2, 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 AXIS:
# ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=0.5)
# ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=0.5)
ax.plot(ax.get_xlim(),[0,0],'k--', linewidth=1 ,zorder=5)
ax.plot([0,0],ax.get_ylim(), 'k--', linewidth=1)
# Plot 1-Parameter Line
line_values= np.array(line_values)
ax.plot(line_values[:,0],line_values[:,1],'k--', linewidth=1,color='orange',alpha=0.8)
ax.set_xlabel(r"$a_1$", fontsize=10 ,labelpad=0)
ax.set_ylabel(r"$a_2$", fontsize=10 ,labelpad=0)
# ax.margins(x=0.5, y=-0.25) # Values in (-0.5, 0.0) zooms in to center
# ax.margins(x=0.5, y=0) # Values in (-0.5, 0.0) zooms in to center
plt.subplots_adjust(left=0.0)
plt.subplots_adjust(bottom=0.1)
plt.rcParams["figure.autolayout"] = True
# ax.get_xaxis().set_visible(False)
# ax = plt.gca(projection="3d")
# ax._axis3don = False
ZL = ax.get_zgridlines()
# 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.view_init(elev=30, azim=-65)
# ax.legend(loc='upper right')
# plt.tight_layout()
# fig.tight_layout()
fig.set_size_inches(width, height)
fig.savefig('1-ParameterFamily_G+.pdf')
plt.show()
## 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
#
# curvature = 1
# create a new 'XML Structured Grid Reader'
if case == 1:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma0-5+5_4000sp.vts'])
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma0.vts'])
if case == 2:
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_infinity-5+5_4000sp.vts'])
phaseDiagram2DGamma_infinity55_4000spvts = XMLStructuredGridReader(FileName=['/home/klaus/Desktop/DUNE/dune-microstructure/outputs/PhaseDiagram2DGamma_infinity.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]
# 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)
# 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()
# 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:
# 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]
# #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
#### 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])
SaveScreenshot('/home/klaus/Desktop/2DPhaseDiagram.png', renderView1, ImageResolution=[2126, 1314])
# export view
# ExportView('/home/klaus/Desktop/PhaseDiagramPlot.pdf', view=renderView1)