#!/usr/bin/gnuplot reset set zero 1.-15 # CHOOSE YOUR OUTPUT FORMAT ##################################### film=0 #set film=0 for visualizing, and 1 for creating images if (film==0) { #set terminal wxt size 1150,800 enhanced} #IDEAL ONE print "WARNING: ideal render using wxt terminal. Yours term is: ", GNUTERM set terminal GNUTERM size 1150,800 enhanced} if (film==1) { #set terminal pngcairo size 2048,1536 enhanced #IDEAL ONE set terminal png size 2048,1536 enhanced print "WARNING: ideal render using pngcairo terminal: uncomment line 11" name_of_file='animation%00005.0f.png' Picnumber=0 outfile = sprintf(name_of_file,Picnumber) set output outfile} # Graph parameters For Fig 1c and Fig 3c ######################### xmin = 13.0 xmax = 18.0 ymin = 14.7 ymax = 18.6 zmin = -5.0 zmax = 0.4 Pz = -10.0 # Position of the bottom plan # Position of the text Tx = 18.0 # X Position Ty = 19 # Y Position Tz = 0.1 # Z Initial position Tzi = 1.5 # Z Increment position #The minimum and saddle points (depends on the function and the x,y,z region) xmin1 = 15.79 #Initial point ymin1 = 16.89 xsad1 = 14.211 ysad1 = 15.709 xsad2 = 17.336 ysad2 = 15.708 xsad3 = 16.679 ysad3 = 17.156 xsad4 = 14.502 ysad4 = 18.299 xsad5 = 13.819 ysad5 = 17.496 # Graph parameters For Fig 9 (other region) ##################### #xmin=17.1 # Graph boundaries #xmax=20.2 #ymin=25.25 #ymax=28.45 #zmin=-3.5 #zmax=0.6 #Pz=-7 # Position of the bottom layer # # Position of the text #Tx=20.4 # Position x for the text #Ty=28.5 # Position y for the text #Tz=0.1 # Position z for the text #Tzi=1.0 # Increment for text position at z # #The minimum and saddle points (depends on the function and the x,y,z region) #xmin1=19.0535 # Initial point #ymin1=27.1841 #xsad1=19.6293 # Saddle points #ysad1=27.5278 #xsad2=17.3733 #ysad2=26.1728 #xsad3=17.3176 #ysad3=28.2734 #xsad4=20.0424 #ysad4=25.9206 #xsad5=19.2621 #The function and its first and second derivatives############## A1=0.5 Bxy1=0.2 Bx1=0.6 By1=0.5 f1(x,y) = A1*cos(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 )) df3_dx(x,y) = A3*( -B3*2.0*(x-X3)) *exp( -B3*( (x-X3)**2.0 + (y-Y3)**2.0 )) d2f3_dx2(x,y) = A3*((-B3*2.0*(x-X3))**2.0-2.0*B3) *exp( -B3*( (x-X3)**2.0 + (y-Y3)**2.0 )) df3_dy(x,y) = A3*( -B3*2.0*(y-Y3)) *exp( -B3*( (x-X3)**2.0 + (y-Y3)**2.0 )) d2f3_dy2(x,y) = A3*((-B3*2.0*(y-Y3))**2.0-2.0*B3) *exp( -B3*( (x-X3)**2.0 + (y-Y3)**2.0 )) d2f3_dxdy(x,y) = A3*( -B3*2.0*(x-X3)) *(-B3*2.0*(y-Y3)) *exp( -B3*( (x-X3)**2.0 + (y-Y3)**2.0 )) f(x,y) = f1(x,y) + f2(x,y) + f3(x,y) df_dx(x,y) = df1_dx(x,y) + df2_dx(x,y) + df3_dx(x,y) df_dy(x,y) = df1_dy(x,y) + df2_dy(x,y) + df3_dy(x,y) d2f_dx2(x,y) = d2f1_dx2(x,y) + d2f2_dx2(x,y) + d2f3_dx2(x,y) d2f_dy2(x,y) = d2f1_dy2(x,y) + d2f2_dy2(x,y) + d2f3_dy2(x,y) d2f_dxdy(x,y) = d2f1_dxdy(x,y) + d2f2_dxdy(x,y) + d2f3_dxdy(x,y) Norme(posx,posy)=(posx**2.0+posy**2.0)**(0.5) #graph style##################################################### #set object rectangle from screen 0,0 to screen 1,1 behind fillcolor 'white' fillstyle solid noborder #If you want a backgroud set lmargin -10 set palette rgb 33,13,10 unset key # unset legend unset border # pas besoin de bordure unset tics # pas besoin de tics unset colorbox #virer palette set parametric #fonctions parametriques set ticslevel 0 set isosamples 230,230 # reduce this to go faster set size 0.85,1.25 set origin -0.105, -0.095 if (film==1){ set size 1.02, 1.235 set origin -0.12, -0.08} set xrange [ xmin : xmax ] noreverse nowriteback set yrange [ ymin : ymax ] noreverse nowriteback set zrange [ Pz : zmax ] noreverse nowriteback set cbrange [ -5.0 : zmax ] noreverse nowriteback set urange [ xmin : xmax ] noreverse nowriteback set vrange [ ymin : ymax ] noreverse nowriteback set hidden3d # Draw the functions############################################# set pm3d lighting specular 0.6 set pm3d noborder set pm3d at bs set view 55,30 ,1.0 set contour both set cntrparam levels 29 do for [i=1:29] {set linetype i lc rgb 'black';} splot u, v, f(u,v) w pm3d at bs ########### Up to line 268: for plotting PES features ############## lab = 10000 # This is to draw the special lines (can take some times) Nx = 200 #increase this for beautiful plot Ny = 200 lenghtV= 0.05 lenghtF= 0.05 do for [ix=1: Nx-1]{ xp=xmin+ix*(xmax-xmin)/Nx do for [iy=1: Ny-1]{ yp=ymin+iy*(ymax-ymin)/Ny Fx=-df_dx(xp,yp) Fy=-df_dy(xp,yp) NormeF=Norme(Fx,Fy) a=d2f_dx2(xp,yp) b=d2f_dxdy(xp,yp) c=d2f_dy2(xp,yp) lmin=0.5*(-(a**2.0-2*a*c+4*b**2.0+c**2.0)**0.5+a+c) lmax=0.5*(+(a**2.0-2*a*c+4*b**2.0+c**2.0)**0.5+a+c) Vx=(lmin-c)/b Vy=1 NormeV=Norme(Vx,Vy) Vx=Vx/NormeV Vy=Vy/NormeV PS=(Fx*Vx+Fy*Vy) if (PS>0){ sign=1.0} else {sign =-1.0} Forthox=Fx-PS*Vx Forthoy=Fy-PS*Vy fperp=Norme(Forthox, Forthoy) fpar =Norme(PS*Vx, PS*Vy) # ################# Plot EV max FIELD ########################## # xpVf=xp-Vxmax*lenghtV*sign # ypVf=yp-Vymax*lenghtV*sign # if (PS>0){ # set arrow lab from xp, yp, f(xp,yp) to xpVf, ypVf, f(xpVf, ypVf) lc "blue" lw 1 nohead front # set arrow lab+1 from xp, yp, Pz to xpVf, ypVf, Pz lc "blue" lw 1 nohead front # lab=lab+2 # } # else{ # set arrow lab from xp, yp, f(xp,yp) to xpVf, ypVf, f(xpVf, ypVf) lc "blue" lw 1 nohead front # set arrow lab+1 from xp, yp, Pz to xpVf, ypVf, Pz lc "blue" lw 1 nohead front # lab=lab+2 # } # ################# Plot Forces FIELD ########################## # xpFf=xp+Fx*lenghtF/NormeF # ypFf=yp+Fy*lenghtF/NormeF # set arrow lab from xp, yp, f(xp,yp) to xpFf, ypFf, f(xpFf, ypFf) lc "green" lw 1 nohead front # set arrow lab+1 from xp, yp, Pz to xpFf, ypFf, Pz lc "green" lw 1 nohead front # lab=lab+2 ################## Plot 1rst Inflexion lines ################# if (abs(lmin)<0.05){ #for area remove abs set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 0.3 lc "blue" front set label lab+1 at xp, yp, Pz "" point pt 7 ps 0.3 lc "blue" front lab=lab+2 } # ################### Plot 2nd Inflexion lines ################# # if (abs(lmax)<0.1){ #for area remove abs # set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 0.2 lc "cyan" front # set label lab+1 at xp, yp, Pz "" point pt 7 ps 0.2 lc "cyan" front # lab=lab+2 # } ##################### Plot Valleys ######################### if (abs(fperp)<0.05 && lmax>0){ set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 0.2 lc "black" front set label lab+1 at xp, yp, Pz "" point pt 7 ps 0.2 lc "black" front lab=lab+2 } ##################### Plot Ridges ######################### if (abs(fperp)<0.05 && lmax<0){ set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 0.3 lc "green" front set label lab+1 at xp, yp, Pz "" point pt 7 ps 0.3 lc "green" front lab=lab+2 } #################### Plot perpendicular hyperplan ######### if (abs(fpar)<0.05 && lmax>0 && lmin>0 ){ set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 0.2 lc "gray90" front set label lab+1 at xp, yp, Pz "" point pt 7 ps 0.2 lc "gray90" front lab=lab+2 } # ################## Plot lmin=lmax ################# # if (abs(lmin-lmax)<0.8){ #for area remove abs # set label lab at xp, yp, f(xp, yp) "" point pt 7 ps 1 lc "black" front # set label lab+1 at xp, yp, Pz "" point pt 7 ps 1 lc "black" front # lab=lab+2 # } } } ############## PLOT MINIMUM AND SADDLE POINTS ################# set label lab at xmin1, ymin1, f(xmin1, ymin1) "" point pt 7 ps 4.0 lc "black" front set label lab+1 at xmin1, ymin1, Pz "" point pt 7 ps 4.0 lc "black" front lab=lab+2 set label lab at xsad1, ysad1, f(xsad1, ysad1) "" point pt 7 ps 4.0 lc "white" front set label lab+1 at xsad1, ysad1, Pz "" point pt 7 ps 4.0 lc "white" front lab=lab+2 set label lab at xsad2, ysad2, f(xsad2, ysad2) "" point pt 7 ps 4.0 lc "yellow" front set label lab+1 at xsad2, ysad2, Pz "" point pt 7 ps 4.0 lc "yellow" front lab=lab+2 set label lab at xsad3, ysad3, f(xsad3, ysad3) "" point pt 7 ps 4.0 lc "green" front set label lab+1 at xsad3, ysad3, Pz "" point pt 7 ps 4.0 lc "green" front lab=lab+2 set label lab at xsad4, ysad4, f(xsad4, ysad4) "" point pt 7 ps 4.0 lc "magenta" front set label lab+1 at xsad4, ysad4, Pz "" point pt 7 ps 4.0 lc "magenta" front lab=lab+2 set label lab at xsad5, ysad5, f(xsad5, ysad5) "" point pt 7 ps 4.0 lc "cyan" front set label lab+1 at xsad5, ysad5, Pz "" point pt 7 ps 4.0 lc "cyan" front lab=lab+2 if (film>=1) { outfile = sprintf(name_of_file,Picnumber) set output outfile Picnumber=Picnumber+1} replot #Lets begin ART############################################################# #ART PARAMETERS################################################## CR_push_size = 0.15 # Size of the push when lowest eigenvalue is positive (into Concex Region) nperp_max_CR = 1 # Number of perpendicular relaxation steps into convex regions perp_factor_init = 0.02 # Initial scaling factor for perpendicular relaxations eigen_thr = 0.0 # Threshold to define when the inflection has been overcomed exit_f_thr = 0.08 # Force threshold to define the saddle point max_displ = 0.15 # Limit the size of the push when it is proportional to forces nsmooth = 1 # Number of smooth steps between random and eigenvector when leaving a convex region nsteps_max = 60 # Maximum number of steps to reach the saddle point alpha = 0.5 # Coeff used in convex region to mix the initial and new random vector (see publication) Nsearch = 25 # Total number of searches to sample the PES do for [i=1: Nsearch]{ # Do Nsearches artn searches for saddle point # ## Initialization ################################################################# ismooth = 1 # initial indice of the number of smooth steps istep = 0 # Indice of the step. Used to limit the max number of steps find = 0 # becomes 1 if saddle point is found lmin = 999 # The lowest eigenvalue lmin_prev = 999 # The previous lowest eigenvalue. Used to detect the change of sign of the eigenvalue perp_factor = perp_factor_init # Used to scale the forces during a relaxation labp = 1 # label for the points representing the intermediate structures Afx=xmin1 # X coord of the starting point Afy=ymin1 # Y coord of the starting point Einit= f(Afx,Afy) # Energy of the starting point # ## Choose initial random direction ################################################# theta=2*pi*(1.0*i/Nsearch) # equipartition of the random direction along a circle #teta2=2*pi*(rand(0)+0.5) # If you want a really random direction Randvectorx=cos(theta) Randvectory=sin(theta) NormeR=Norme(Randvectorx,Randvectory) Randvectorx=Randvectorx/NormeR Randvectory=Randvectory/NormeR dRandx=Randvectorx dRandy=Randvectory # Normalized random direction # ## PUSH TO SADDLE ################################################################## while ( find==0 && istep0){sign=-1.0} else {sign=1.0} # # Chose Push direction and size if ( lminmax_displ) {size_push=max_displ} # Limit the size of the push Pushx=sign*Vx # Push direction is along eigenvector and opposite to parallel force Pushy=sign*Vy} } # if ( lmin>eigen_thr ) {####################################### Bellow inflection (into convex region) nperp_max = 1 # No need to do a lot of perp relaxation steps into convex regions ismooth = 1 # Reset ismooth to be able to redo a smooth step size_push = CR_push_size # Constant push size into convex regions if (lmin_prev<0) { # This means the system is into a new convex region teta2=2*pi*(rand(0)) # Chose a new normalized random vector Randvector2x=cos(teta2) Randvector2y=sin(teta2) NormeR2=Norme(Randvector2x,Randvector2y) Randvector2x=Randvector2x/NormeR2 Randvector2y=Randvector2y/NormeR2 dRandx=alpha*Randvectorx+(1.0-alpha)*Randvector2x # Optimal idea (for now) dRandy=alpha*Randvectory+(1.0-alpha)*Randvector2y #dRandx=Vx # Bad idea that always retuns the same saddle #dRandy=Vy NormeR=Norme(dRandx,dRandy) dRandx=dRandx/NormeR dRandy=dRandy/NormeR } Pushx = dRandx Pushy = dRandy } # ## This is the push along the chosen direction Push and amplitude size_push Afx=Afx+size_push*Pushx Afy=Afy+size_push*Pushy set label labp at Afx, Afy, Pz "" point pt 7 ps 1.0 lc "black" front set label labp at Afx, Afy, f(Afx,Afy) "" point pt 7 ps 1.0 lc "black" front labp=labp+2 # Uncomment if you want to see progressivelly the trajectory #if (film>=1) { # outfile = sprintf(name_of_file,Picnumber) # set output outfile # Picnumber=Picnumber+1} #replot ## Orthogonal Relaxation ############################# irelax=0 # number of relaxation steps fperp=99999 # Huge starting fperp fpar=0 # Small starting fpar try=0 # number of allowed failed attemps due to too big steps Afxold=Afx # Save previous position Afyold=Afy while ( irelaxfpar ){ Fx=-df_dx(Afx,Afy) # Calculate forces and its componants... Fy=-df_dy(Afx,Afy) NormeF=Norme(Fx,Fy) PS=(Pushx*Fx+Pushy*Fy) Forthox=Fx-PS*Pushx Forthoy=Fy-PS*Pushy fperp=Norme(Forthox, Forthoy) # Perpendicular fpar =Norme(PS*Pushx, PS*Pushy) # and Parallel if (perp_factor>max_displ/fperp){perp_factor=max_displ/fperp} # limit the maximum size of the step Afxold=Afx Afyold=Afy Afx= Afxold+Forthox*perp_factor Afy= Afyold+Forthoy*perp_factor E= f(Afx,Afy) # Calculate new energy if ( E < f(Afxold,Afyold) ){ # If E decreases perp_factor= perp_factor*1.2 # Then increase the scaling coef irelax=irelax+1 } else{ perp_factor= perp_factor*0.7 # else decrease it try=try+1 Afx=Afxold Afy=Afyold} # These 12 lines are only for printing some information set label 2000 at Tx,Ty, Tz-Tzi*0 sprintf("X= %6.3f", Afx) tc "black" font "Times-Roman, 32" set label 2001 at Tx,Ty, Tz-Tzi*1 sprintf("Y= %6.3f", Afy) tc "black" font "Times-Roman, 32" set label 2002 at Tx,Ty, Tz-Tzi*2 sprintf("DE= %6.3f", E-Einit) tc "black" font "Times-Roman, 32" set label 2003 at Tx,Ty, Tz-Tzi*3 sprintf("{/Symbol l}min= %6.3f", lmin) tc "black" font "Times-Roman, 32" set label 2004 at Tx,Ty, Tz-Tzi*4 sprintf("F= %6.3f", NormeF) tc "black" font "Times-Roman, 32" set label 2005 at Tx,Ty, Tz-Tzi*5 sprintf("Fpar= %6.3f", fpar) tc "black" font "Times-Roman, 32" set label 2006 at Tx,Ty, Tz-Tzi*6 sprintf("Fperp= %6.3f", fperp) tc "black" font "Times-Roman, 32" set label 2007 at Tx,Ty, Tz-Tzi*7 sprintf("Perp relax= %2.0f/%2.0f", irelax, nperp_max) tc "black" font "Times-Roman, 32" set label 2008 at Tx,Ty, Tz-Tzi*8 sprintf("Pushs= %3i", istep) tc "black" font "Times-Roman, 32" set label labp at Afx, Afy, Pz "" point pt 7 ps 1.0 lc "black" front set label labp+1 at Afx, Afy, f(Afx,Afy) "" point pt 7 ps 1.0 lc "black" front # Uncomment if you want to see progressivelly the trajectory #if (film>=1) { # outfile = sprintf(name_of_file,Picnumber) # set output outfile # Picnumber=Picnumber+1} #replot } # Check if saddle has been found if( (lmin<0) && (NormeF=1) { # This is for creating an image outfile = sprintf(name_of_file,Picnumber) set output outfile Picnumber=Picnumber+1} replot #pause mouse any # Uncomment if you want to make a pause do for [ilabp=1:999]{ # Remove the points unset label ilabp } } #end of the do loop over the Nsearch artn searches