Tuesday, May 13, 2014

fortran learning-how to convert a number to a character and vice-versa.

1. Character initialization
character*10 string, format
CHARACTER :: char1,char2,letter="I"
CHARACTER, PARAMETER :: a="a",b="b",c="c"
CHARACTER (LEN=6) :: class1=’MT3501’, class2=’MT3502’
,class3=’MT3503’
CHARACTER (LEN=*), PARAMETER :: headline="Man United will win the league?"
CHARACTER (LEN=5), PARAMETER :: name="Steve"

2. how to convert a number to a character and vice-versa.

program characterconversions

character*50 s
integer i
double precision d
logical t,f

s = '1234' 
read (s,*) i

s = '1234.5678'
read (s,*) d

s = 'T' !TRUE
read (s,*) t

s = 'F' !FALSE
read (s,*) f

print *,i
print *,d
print *,t
print *,f

write (s, *) i
print *,s

write (s, *) d
print *,s

write (s, *) t
print *,s

write (s, *) f
print *,s

print '("Press any key to exit... "$)'
read (*,*)

end

THE OUTPUT IS:

1234
1234.5678
T
F
1234
1234.5678
T
F
Press any key to exit...

3. How to operate the characters and strings.

PROGRAM characters
IMPLICIT NONE
CHARACTER (LEN=*), PARAMETER :: headline="Man United will win the league?"
CHARACTER (LEN=*), PARAMETER :: fname="Steve", lname="Smith"
CHARACTER (LEN=11) :: fullname ! *** Example of concatenation of two strings ***
fullname=fname//lname
PRINT*,fullname !*** Concatenation of a string a character and a string ***
fullname=fname//" "//lname
PRINT*,fullname ! *** Example of a substring ***
PRINT*,headline(5:10)
end program

Tuesday, May 6, 2014

how to choose gnuplot font and one gunplot script

set terminal jpeg font "arial" 14

set xrange [0:200000]
plot "ENERGIES-backup" u 1:($4+55.9)*2625.50/4.18 t "Eks vs time" w l
set output "Eksvstime.jpg"
set terminal jpeg font "arial" 14
replot

q1: how to know your default font in your gnuplot program?
In general, gnuplot> help
                    gnuplot>fonts
You will see the default font. In general, it should be Arial.

Thursday, May 1, 2014

cpmd learning notes

If we want to study some systems, for example chemical reactions, we do better to use the non-PBC conditions. Why? Because generally we need use the radius of gyration in the PLUMED manual. Here I imply we should use biased AIMD, i.e. metadynamics.

If you use the radius of gyration, you should realize this method is not appropriate for PBC condition (read the PLUMED manual). However, if you use the non-PBC condition, you have to worry about the fragments or radicals such as hydrogen atoms could fly away and cross the box boundaries. This crossing could cause bad problems for AIMD simulations because you will have nonphysical results.

So another suggestion is that you should add more constraints such as harmonic potential on every individual hydrogen atom and mass center of the whole system. This way you can make sure the lightest fragments fly away.