ternaus / quest-qmc

Automatically exported from code.google.com/p/quest-qmc
2 stars 11 forks source link

Output for the bipartite vs frustrated lattice. #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
If I try to do simulation with square lattice I get as a part of the output.
----
Equal time measurements:
          Up spin occupancy :   0.49441408E+00 +-  0.27906138E-02
        Down spin occupancy :   0.49441408E+00 +-  0.27906138E-02
             <U*N_up*N_dn>  :  -0.61030465E+00 +-  0.40210805E-02
             Kinetic energy :  -0.42151330E+00 +-  0.48807929E-02
               Total energy :  -0.15318180E+01 +-  0.35233139E-02
                    Density :   0.98882816E+00 +-  0.55812276E-02
                Chi_thermal :   0.31657720E+02 +-  0.40406090E+00
              Specific heat :  -0.81868631E+02 +-  0.68030391E+00
  XX Ferro structure factor :   0.12699407E+00 +-  0.20654373E-02
  ZZ Ferro structure factor :   0.12699407E+00 +-  0.20654373E-02
     XX AF structure factor :   0.57196287E+00 +-  0.45767125E-02
  Root Mean Square of XX AF :   0.57436706E+00 +-  0.44351034E-02
     ZZ AF structure factor :   0.57196287E+00 +-  0.45767125E-02
  Root Mean Square of ZZ AF :   0.57436706E+00 +-  0.44351034E-02
           Potential energy :  -0.12147648E+00 +-  0.31098157E-02
             Hopping energy :  -0.14103415E+01 +-  0.63863610E-02
           Double occupancy :   0.30515232E+00 +-  0.20105403E-02
      Magnetization squared :   0.94630879E-01 +-  0.77745392E-03
----
and this is what I want.

But if I want to do simulation for triangular lattice I get:
----
Equal time measurements:
          Up spin occupancy :   0.45788455E+00 +-  0.13289503E-02
        Down spin occupancy :   0.45768401E+00 +-  0.19869801E-02
             <U*N_up*N_dn>  :   0.54909898E+00 +-  0.20308874E-02
             Kinetic energy :  -0.38211706E+01 +-  0.59956938E-02
               Total energy :  -0.22720716E+01 +-  0.63185666E-02
                    Density :   0.91556856E+00 +-  0.19221705E-02
                Chi_thermal :  -0.58407171E+02 +-  0.28219871E+00
              Specific heat :   0.35458869E+03 +-  0.17570769E+01
  XX Ferro structure factor :   0.75732930E-01 +-  0.68811243E-02
  ZZ Ferro structure factor :   0.71791457E-01 +-  0.40343347E-02
----

Where are Potential energy, Hopping energy, Double occupancy and       
Magnetization squared?

Original issue reported on code.google.com by iglovi...@gmail.com on 13 Apr 2014 at 3:34

Attachments:

GoogleCodeExporter commented 9 years ago
Right now output that prints scalar measurements works in such a manner:

Everything is defined in the file dqmc_phy0.F90

----

There are variables:
P0_N_NO_SAF - which defines number of variables that can be defined for both 
bipartite and frustrated lattice.

P0_N - total number of scalar variables.

where 

P0_N should be >= P0_N_NO_SAF

P0%compSAF - True if lattice is bipartite
             False if lattice is frustrated

P0%nMeas - number of scalar variables that will go to the output

If P0%compSAF == True:
  P0%nMeas = P0_N
if P0%compSAF == False:
  P0%nMeas = P0_N_NO_SAF

Which means that if lattice is frustrated we print only first P0_N_NO_SAF 
variables,
if not we will print all P0_N variables.

This can look fine because it works, but this is really crappy code. Problem 
that it is 
hard to scale. And reason for this is that if you need to add new ferromagnetic 
variables you need:

change variables:
  integer, parameter :: P0_SAF
  integer, parameter :: P0_SAFSQ
  integer, parameter :: P0_SAF2
  integer, parameter :: P0_SAF2SQ
  integer, parameter :: P0_N_NO_SAF
  integer, parameter :: P0_N

and add label for the variable that you want to add in character(len=*), 
parameter :: P0_STR(P0_N) in proper space.

So you have number of ways to create a bug from nowhere.

I do not know how wrote this "amazing" code but it should be changed at some 
point.

I am changing this from defect to enhancement but it is still not ok.

Original comment by iglovi...@gmail.com on 13 Apr 2014 at 4:57

GoogleCodeExporter commented 9 years ago
Vlad,

this is not so bad. I am also unhappy about it but I don't think that this is 
in any way serious: it is too simple of a piece of code for
people to get confused or introduce bugs that are hard to track. 
We could and should definitely make this better. What do you have in mind? 
I am thinking linked list but there may be better/simpler ways.

For everyone's benefit, I am copying below an email I sent Vlad on how
to add a new scalar measurement but mended with a new paragraph to 
avoid what Vlad is seeing.

----

I am going to assume the property is just a single number like
the double occupancy.

At the very  beginning of DQMC_Phy0 you see a bunch of parameter
definition (P0_NUP, P0_DN...) which is just an emulation of C/C++ enum.

So the first step in adding an observable is adding an entry here. Note that the
number of variables is either P0_N or P0_N_NO_SAF depending on the
value of P0%compSAF (see DQMC_Phy0_Init). These constants will both need
to be incremented. Something like this will do

  ! Parameter for the index of scalar variables (IMEAS)
  integer, parameter :: P0_NUP       = 1
  integer, parameter :: P0_NDN       = 2
  integer, parameter :: P0_NUD       = 3
  integer, parameter :: P0_KE        = 4
  integer, parameter :: P0_ENERGY    = 5
  integer, parameter :: P0_DENSITY   = 6
  integer, parameter :: P0_CHIT      = 7
  integer, parameter :: P0_CV        = 8
  integer, parameter :: P0_VLAD      = 9

  integer, parameter :: P0_SFERRO    = 10
  integer, parameter :: P0_SFER2     = 11
  integer, parameter :: P0_SAF       = 12
  integer, parameter :: P0_SAFSQ     = 13
  integer, parameter :: P0_SAF2      = 14
  integer, parameter :: P0_SAF2SQ    = 15

  integer, parameter :: P0_N_NO_SAF  = 11
  integer, parameter :: P0_N         = 15

-->Note that the new property (P0_VLAD) will *need* to be added before
the "P0_SAF" properties. Here I add it at number 9 which means that anything
after will need its index incremented by one. There's certainly a better way
to do this.<--

Then add the corresponding "label" for printing like so

  ! Name of scalar variables
  character(len=*), parameter :: P0_STR(P0_N) = (/&
       "          Up spin occupancy : ", &
       "        Down spin occupancy : ", &
       "             <U*N_up*N_dn>  : ", &
       "             Kinetic energy : ", &
       "               Total Energy : ", &
       "                    Density : ", &
       "                Chi_thermal : ", &
       "              Specific heat : ", &
       "           Vlad new property:",&
       "  XX Ferro structure factor : ", &
       "  ZZ Ferro structure factor : ", &
       "     XX AF structure factor : ", &
       "  Root Mean Square of XX AF : ", &
       "     ZZ AF structure factor : ", &
       "  Root Mean Square of ZZ AF : "/)

Finally code up the actual measurement in DQMC_Phy0_Meas

P0%meas(P0_VLAD,tmp) = "some product/sum of G's"

----

Simone

Original comment by simone.c...@gmail.com on 13 Apr 2014 at 11:18