//  CRITTEMP.C
//  © 2021 Peter J. Meyer

#include "iss.h"

//  Critical temperature depends not only on model and dimensionality
//  but also on lattice type.

//  Returns critical temperature of the current spin model
//  or -1 if not known.
/*---------------------------------*/
double get_critical_temperature(void)
{
int i;

if ( model_is_ising )
    return ( lattice_types[l_type].ising_crit_temp );
else    //  model is q-state Potts
    {
    for ( i=0; i<NUM_LATTICE_TYPES; i++ )
        {
        if ( !strcmp(lattice_types[i].name,"square") )
            break;
        }
    if ( l_type == i )
        return ( 1/log(1+sqrt(q)) );
        //  Calculate critical temperatures for square q-state Potts models
        //  following Okano, et al., "Universality & Scaling in Short-time Critical Dynamics".
    else
        return ( -1 );
        //  Critical temperature for non-square q-state Potts models not known at this time.
    }
}

#if false

/*--------------------------------*/
void set_critical_temperatures(void)
{
int i,j,qq;

#if false
for ( i=0; i<=MAX_DIMENSIONALITY; i++ )
    for ( j=0; j<NUM_LATTICE_TYPES; j++ )
        ising_critical_temperatures[i][j] = -1.0;

for ( i=0; i<=MAX_DIMENSIONALITY; i++ )
    for ( j=0; j<NUM_LATTICE_TYPES; j++ )
        for ( qq=0; qq<=MAX_Q_VALUE; qq++ )
            potts_critical_temperatures[i][j][qq] = -1.0;
#endif

//  Calculate pure Ising 2d square model critical temperature
//  using formula given on p.177 of Stinchcombe's 1983 article
//  on "Dilute Magnetism", Tc = 2J*[KB*ln(1+sqrt(2)]^-1 
//  with J = 1 and KB = 1:

for ( i=0; i<NUM_LATTICE_TYPES; i++ )
    {
    if ( !strcmp(lattice_types[i].name,"square") )
        break;
    }

ising_square_critical_temp = critical_temperatures[2][i] 
    =  2/log(1+sqrt(2));

for ( i=0; i<NUM_LATTICE_TYPES; i++ )
    {
    if ( !strcmp(lattice_types[i].name,"cubic") )
        break;
    }

ising_cubic_critical_temp = critical_temperatures[3][i] 
    =  4.511536;     //  Heuer, H.-0., 1992, J.Phys.A, L567

//  Calculate critical temperatures for square q-state Potts models
//  following Okano, et al., "Universality & Scaling in Short-time Critical Dynamics".

for ( i=0; i<NUM_LATTICE_TYPES; i++ )
    {
    if ( !strcmp(lattice_types[i].name,"square") )
        break;
    }

for ( qq=2; qq<=MAX_Q_VALUE; qq++ )
    potts_critical_temperatures[2][i][qq] = 1/log(1+sqrt(qq));
    //  critical_temperatures[Q_STATE_POTTS_MODEL][2][qq] = 2/log(1+sqrt(qq));

//  Potts critical temperatures for non-square lattices not known at this point.
}

#endif