Exemplo n.º 1
0
// System to solve (D1, Mu_b) with X, Mu_h and Beta fixed
func Mu_bSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"Mu_b"}
	diffMu_b := AbsErrorBeta(env, variables)
	system := solve.Combine([]solve.Diffable{diffMu_b})
	start := []float64{env.Mu_b}
	return system, start
}
Exemplo n.º 2
0
func NoninteractingSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "Mu_h"}
	diffD1 := AbsErrorD1Noninteracting(env, variables)
	diffMu_h := AbsErrorMu_hNoninteracting(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffMu_h})
	start := []float64{env.D1, env.Mu_h}
	return system, start
}
Exemplo n.º 3
0
// For use with solve.MultiDim:
// T_c convergence is better if we solve for D1 and Mu_h first.
func CritTempD1MuSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "Mu_h"}
	diffD1 := tempPair.AbsErrorD1(env, variables)
	diffMu_h := tempPair.AbsErrorBeta(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffMu_h})
	start := []float64{env.D1, env.Mu_h}
	return system, start
}
Exemplo n.º 4
0
// For use with solve.Iterative:
func CritTempStages(env *tempAll.Environment) ([]solve.DiffSystem, []vec.Vector, func([]vec.Vector)) {
	vars0 := []string{"D1", "Mu_h"}
	vars1 := []string{"Beta"}
	diffD1 := tempPair.AbsErrorD1(env, vars0)
	diffMu_h := tempPair.AbsErrorBeta(env, vars0)
	system0 := solve.Combine([]solve.Diffable{diffD1, diffMu_h})
	diffBeta := AbsErrorBeta(env, vars1)
	system1 := solve.Combine([]solve.Diffable{diffBeta})
	stages := []solve.DiffSystem{system0, system1}
	start := []vec.Vector{[]float64{env.D1, env.Mu_h}, []float64{env.Beta}}
	accept := func(x []vec.Vector) {
		env.D1 = x[0][0]
		env.Mu_h = x[0][1]
		env.Beta = x[1][0]
	}
	return stages, start, accept
}
Exemplo n.º 5
0
func PairTempSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "Mu_h", "Beta"}
	diffD1 := AbsErrorD1(env, variables)
	diffMu_h := AbsErrorMu_h(env, variables)
	diffBeta := AbsErrorBeta(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffMu_h, diffBeta})
	start := []float64{env.D1, env.Mu_h, env.Beta}
	return system, start
}
Exemplo n.º 6
0
func ZeroTempSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "Mu_h", "F0"}
	diffD1 := AbsErrorD1(env, variables)
	diffMu_h := AbsErrorMu_h(env, variables)
	diffF0 := AbsErrorF0(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffMu_h, diffF0})
	start := []float64{env.D1, env.Mu_h, env.F0}
	return system, start
}
Exemplo n.º 7
0
func D1F0XSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "F0", "X"}
	diffD1 := AbsErrorD1(env, variables)
	diffF0 := AbsErrorF0(env, variables)
	diffX := AbsErrorX(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffF0, diffX})
	start := []float64{env.D1, env.F0, env.X}
	return system, start
}
Exemplo n.º 8
0
// System to solve (D1, Mu_b, x) with Mu_h and Beta fixed
func D1Mu_bXSystem(env *tempAll.Environment) (solve.DiffSystem, []float64) {
	variables := []string{"D1", "Mu_b", "X"}
	diffD1 := tempPair.AbsErrorD1(env, variables)
	diffMu_b := AbsErrorMu_b(env, variables)
	diffX := AbsErrorX(env, variables)
	system := solve.Combine([]solve.Diffable{diffD1, diffMu_b, diffX})
	start := []float64{env.D1, env.Mu_b, env.X}
	return system, start
}
Exemplo n.º 9
0
// Regression test: solution for D1 in default environment should stay constant
func TestSolveAbsErrorD1(t *testing.T) {
	solution_expected := 0.05139504320378395
	env, err := d1DefaultEnv()
	if err != nil {
		t.Fatal(err)
	}
	diffD1 := AbsErrorD1(env, []string{"D1"})
	system := solve.Combine([]solve.Diffable{diffD1})
	start := []float64{env.D1}
	epsabs := 1e-8
	epsrel := 1e-8
	solution, err := solve.MultiDim(system, start, epsabs, epsrel)
	if err != nil {
		t.Fatal(err)
	}
	errabs, err := diffD1.F([]float64{env.D1})
	if err != nil {
		t.Fatal(err)
	}
	if math.Abs(solution[0]-solution_expected) > epsabs || math.Abs(errabs) > epsabs {
		t.Fatalf("incorrect D1 solution (got %v, expected %v); error is %v", solution[0], solution_expected, errabs)
	}
}