Exemplo n.º 1
0
int half_cycle(GLASS_SK *sys, double H1, double H2){
	// Quench the system from H1 to H2 with a step of h.
	// When it goes across 0, record the optimal energy and the configuration.
	// Return how many queches happens in a half cycle.

	int i, j, quench_time = 0;
	double delta;

	/* Quench at H1 */
	delta = H1 / 20.0;
	sys->H = H1;
	update_sys(sys);	/* Calibrate the status of the system */
	quench_time += quench(sys);
	for(i = 1; i < 20; i++){
		decrease_H(sys, delta);
		quench_time += quench(sys);
		// printf("%.6f\t", (sys->energy+sys->H*sys->magnetization)/sys->N);
		// printf("%.6f\t%.6f\n", sys->H, sys->magnetization/sys->N);
	}

	/* Quench at 0 */
	sys->H = 0;
	update_sys(sys);
	quench_time += quench(sys);
	// printf("%.6f\t", (sys->energy+sys->H*sys->magnetization)/sys->N);
	// printf("%.6f\t%.6f\n", sys->H, sys->magnetization/sys->N);


	/* Check the best configuration */
	if(sys->energy_stable > sys->energy){
		sys->energy_stable = sys->energy;
		for(i = 0; i < sys->N; i++)
			sys->sigma_best[i] = sys->sigma[i];
	}
	// FILE *cycle = fopen("energy.dat", "at");
	// fprintf(cycle, "%.6f\t%.6f\n", sys->energy_stable/sys->N, sys->energy/sys->N);
	// fclose(cycle);

	/* Quench from 0 to H2 */
	delta = - H2 / 20.0;
	for(i = 0; i < 20; i++){
		decrease_H(sys, delta);
		quench_time += quench(sys);
		// printf("%.6f\t", (sys->energy+sys->H*sys->magnetization)/sys->N);
		// printf("%.6f\t%.6f\n", sys->H, sys->magnetization/sys->N);
	}

	return quench_time;
}
Exemplo n.º 2
0
void    text_to_cheats(void)
{
    static int      last_command = 0;
    int             command;
    char            command_text[0x100];


    retrieve_input_string(command_text, 10);
    g_text_activated = true;
    if (match(command_text, "bis")) command = BIS;
    else if (match(command_text, "quench")) command = QUENCH;
    else if (match(command_text, "savetp")) command = SAVETP;
    else if (match(command_text, "restoretp")) command = RESTORETP;
    if (command != last_command)
    {
    bis:
        switch (command)
        {
            case BIS:
                command = last_command;
                goto bis;
                break;
            case QUENCH:
                quench();
                break;
            case SAVETP:
                save_teleport();
                break;
            case RESTORETP:
                restore_teleport();
                break;
            default:
                break;
        }
        last_command = command;
    }
    g_text_activated = false;  
}