Skip to content

Commit

Permalink
Bugfix: Modified field cooling loop to avoid stepwise temperature cha…
Browse files Browse the repository at this point in the history
…nge for partial-time > 1
  • Loading branch information
richard-evans committed Apr 22, 2015
1 parent 656d46d commit b6c97b0
Showing 1 changed file with 32 additions and 28 deletions.
60 changes: 32 additions & 28 deletions src/program/field_cool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,34 +103,38 @@ void field_cool(){
// Perform Field Cooling
while(sim::time<sim::total_time+start_time){

// Calculate Temperature using desired cooling function
double time_from_start=mp::dt_SI*double(sim::time-start_time);
switch(sim::cooling_function_flag){
case 0:{ // exponential
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-time_from_start/sim::cooling_time);
}
break;
case 1:{ // gaussian
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-(time_from_start)*(time_from_start)/((sim::cooling_time)*(sim::cooling_time)));
}
break;
case 2:{ // double-gaussian
double centre_time = 3.0*sim::cooling_time;
double time_from_centre=mp::dt_SI*double(sim::time-start_time)-centre_time;
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-(time_from_centre)*(time_from_centre)/((sim::cooling_time)*(sim::cooling_time)));
}
break;
case 3:{ // linear
double Tlinear = sim::Tmax-(sim::Tmax-sim::Tmin)*(time_from_start/sim::cooling_time);
if(Tlinear>=sim::Tmin) sim::temperature = Tlinear;
else sim::temperature= sim::Tmin;
}
break;
}

// Integrate system
sim::integrate(sim::partial_time);

// loop over partial time
for(int tt=0; tt < sim::partial_time; tt++){

// Calculate Temperature using desired cooling function
double time_from_start=mp::dt_SI*double(sim::time-start_time);
switch(sim::cooling_function_flag){
case 0:{ // exponential
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-time_from_start/sim::cooling_time);
}
break;
case 1:{ // gaussian
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-(time_from_start)*(time_from_start)/((sim::cooling_time)*(sim::cooling_time)));
}
break;
case 2:{ // double-gaussian
double centre_time = 3.0*sim::cooling_time;
double time_from_centre=mp::dt_SI*double(sim::time-start_time)-centre_time;
sim::temperature = sim::Tmin + (sim::Tmax-sim::Tmin)*exp(-(time_from_centre)*(time_from_centre)/((sim::cooling_time)*(sim::cooling_time)));
}
break;
case 3:{ // linear
double Tlinear = sim::Tmax-(sim::Tmax-sim::Tmin)*(time_from_start/sim::cooling_time);
if(Tlinear>=sim::Tmin) sim::temperature = Tlinear;
else sim::temperature= sim::Tmin;
}
break;
}

// Integrate system
sim::integrate(1);
}

// Calculate magnetisation statistics
stats::mag_m();

Expand Down

0 comments on commit b6c97b0

Please sign in to comment.