Skip to content
Snippets Groups Projects
Commit c0b1771e authored by Andrew E. Torda's avatar Andrew E. Torda
Browse files

Cleaning of tests and output files.

parent 3cb50a6e
No related branches found
No related tags found
No related merge requests found
......@@ -19,111 +19,62 @@ ini_temp = 1
final_temp 0
x_ini 0.8,0.8,0.8
x_delta, "0.4"
n_step = 100000
fOutNamen testReal`
n_step = 100000`
func TestTypo(t *testing.T) { // Make sure a typo in input does provoke an error
if err := realmain(strings.NewReader(sTypo)); err == nil {
t.Fatal("line with typo should provoke error\n", err, "\nInput", sTypo)
}
}
type gentest struct{ params, basename string }
var s1d = `
var set1 = []gentest{
{`
ini_temp 1e-10
final_temp 1e-12
x_ini 1,1,1
n_step 10000`, "cold"},
{`
ini_temp 1
final_temp 0.05
x_ini 15
n_step 10000
fOutName testanneal1d`
var s16d = `
n_step 10000`, "s1d"},
{`
ini_temp 0.02
final_temp 0.001
x_ini 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
n_step 1000000
x_delta 1
fPltName anneal16d.svg
xPltName anneal16dtrajplt
fOutName anneal16d`
var sCold = `
ini_temp 1e-10
final_temp 1e-12
x_ini 1,1,1
n_step 10000
fOutName testcold`
var sHot = `
x_delta 1`, "s16d"},
{`
ini_temp 1
final_temp 1
x_ini 1,1,1
n_step 10000
fOutName testhot`
var sRealAnneal = `
ini_temp 0.5
final_temp 0.05
x_ini 7,1,7
n_step 100000
fOutName ""`
// These values seem to work well. There is something of a phase
// transition near temperature 0.09. Good values for an optimisation
// seem to be 0.17 and 0.01 (initial and final temperatures), but this
// needs a few steps (500000).
// constant temp..
// 0.75 jump around and nicely visits all locations
// 0.1 jumps around, acceptance is too high and really uncontrolled.
// 0.09375 visit 0, 1, 2, 3, 4, 5, 6, .. Can fully explore local minima and sometimes get to next
// 0.0875 visits 6.7, 6.8, .. 7.2
// 0.075 only see points at 6.8, 6.9, 7.0, 7.1
// 0.05 only see points at 6.8, 6.9, 7.0, 7.1
var sPhaseTrans = `
fOutName testhot`, "hot"},
{`
ini_temp 0.18
final_temp 0.01
x_ini 7,1,7
n_step 100000
fOutName testphase`
var csv_test = []string{
s1d, sHot, sCold, sRealAnneal, sPhaseTrans, s16d}
n_step 100000`, "phasetrans"},
func TestCsv(t *testing.T) {
for _, s := range csv_test {
if err := realmain(strings.NewReader(s)); err != nil {
t.Fatal("csv failed with\n", err, "\nInput:", s)
}
}
}
var s9dplot = `
ini_temp 0.0925
final_temp 0.09
x_ini 15,10,11,12,14,18,-12,-8,-9
n_step 50000
x_delta 0.2
fOutName test9d
fPltName testplot.svg
xPltName testrajplt`
var s9bdplot = `
ini_temp 0.0925
final_temp 0.05
x_ini 15,10,11,12,14,0,-12,-8,-9
n_step 50000
x_delta 0.2
fOutName test9db
fPltName test9dbf
xPltName test9dbtraj`
var plotTest = []string{
s9dplot, s9bdplot,
// add OutNames uses the basename field and makes output names for
// the value and x trajectory plot files and the csv file
func addOutNames (s gentest) string {
a := []string {"xPltName", "fPltName", "fOutName"}
ret := s.params
for _, ss := range a {
ret += "\n" + ss + " " + s.basename
}
func TestPlot(t *testing.T) {
for _, s := range plotTest {
if err := realmain(strings.NewReader(s)); err != nil {
t.Fatal("plot test failed with\n", err, "\nInput", s)
return ret + "\n"
}
func Test1(t *testing.T) {
for _, s:= range set1 {
instring := addOutNames(s)
if err := realmain(strings.NewReader(instring)); err != nil {
t.Fatal("set1 failed with\n", err, "\nInput:", s)
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment