Example #1
0
// Solve the (D1, Mu_h, F0) system with x and Beta fixed.
func D1MuF0Solve(env *tempAll.Environment, epsAbs, epsRel float64) (vec.Vector, error) {
	if env.A == 0.0 && env.B == 0.0 {
		// We must have T < T_c < T_p (Beta > Beta_c > Beta_p).
		// Getting Beta_p is fast, so do that first.
		D1, Mu_h, F0, Beta := env.F0, env.Mu_h, env.F0, env.Beta // cache env
		env.F0 = 0.0                                             // F0 is 0 at T_c and T_p
		_, err := tempPair.PairTempSolve(env, epsAbs, epsRel)
		if err != nil {
			return nil, err
		}
		if Beta < env.Beta {
			return nil, fmt.Errorf("Beta = %f less than Beta_p in env %s", Beta, env.String())
		}
		_, err = tempCrit.CritTempSolve(env, epsAbs, epsRel)
		if err != nil {
			return nil, err
		}
		if Beta < env.Beta {
			return nil, fmt.Errorf("Beta = %f less than Beta_c in env %s", Beta, env.String())
		}
		fmt.Printf("%v; Tc = %f\n", env, 1.0/env.Beta)
		omegaFit, err := tempCrit.OmegaFit(env, tempCrit.OmegaPlus)
		if err != nil {
			return nil, err
		}
		env.A, env.B = omegaFit[0], omegaFit[2]
		env.PairCoeffsReady = true
		// we are at T < T_c; uncache env
		env.D1, env.Mu_h, env.F0, env.Beta = D1, Mu_h, F0, Beta
	}
	// solve low temp system for reasonable values of D1 and Mu_h first
	_, err := D1MuSolve(env, epsAbs, epsRel)
	if err != nil {
		return nil, err
	}
	// solve the full low temp system
	system, start := D1MuF0System(env)
	solution, err := solve.MultiDim(system, start, epsAbs, epsRel)
	if err != nil {
		return nil, err
	}
	return solution, nil
}
Example #2
0
// Solve the (D1, Mu_h, Mu_b) system with Beta and x fixed.
func SolveD1Mu_hMu_b(env *tempAll.Environment, epsAbs, epsRel float64) (vec.Vector, error) {
	/*
		// fix pair coefficients
		if env.A == 0.0 && env.B == 0.0 && env.FixedPairCoeffs {
			D1, Mu_h, Mu_b, Beta, Be_field := env.D1, env.Mu_h, env.Mu_b, env.Beta, env.Be_field
			env.Mu_b = 0.0 // Mu_b is 0 at T_c
			env.Be_field = 0.0
			_, err := tempCrit.CritTempSolve(env, epsAbs, epsRel)
			if err != nil {
				return nil, err
			}
			omegaFit, err := tempCrit.OmegaFit(env, tempCrit.OmegaPlus)
			if err != nil {
				return nil, err
			}
			env.A, env.B = omegaFit[0], omegaFit[2]
			env.PairCoeffsReady = true
			// uncache env
			env.D1, env.Mu_h, env.Mu_b, env.Beta, env.Be_field = D1, Mu_h, Mu_b, Beta, Be_field
		}
	*/
	maxIters := 1000
	oldMu_b := env.Mu_b
	for i := 0; i < maxIters; i++ {
		// iterate D1/Mu_h
		solution, err := SolveD1Mu_h(env, epsAbs, epsRel)
		if err != nil {
			return nil, err
		}
		// iterate Mu_b
		Be_field := env.Be_field
		env.Be_field = 0.0
		zv := vec.ZeroVector(3)
		omega0, err := tempCrit.OmegaPlus(env, zv)
		//omegaFit, err := tempCrit.OmegaFit(env, tempCrit.OmegaPlus)
		if err != nil {
			return nil, err
		}
		env.Mu_b = -omega0
		env.Be_field = Be_field
		//A, Mub_eff := omegaFit[0], omegaFit[3]
		//env.Mu_b = -omega0 + 2.0 * env.Be_field * env.A
		//Mub_eff := omegaFit[3]
		//env.Mu_b = Mub_eff
		//fmt.Printf("iterating Mu_b: now %f, before %f\n", env.Mu_b, oldMu_b)
		// check if done
		if math.Abs(env.Mu_b-oldMu_b) < epsAbs || !env.IterateD1Mu_hMu_b {
			return []float64{solution[0], solution[1], env.Mu_b}, nil
		}
		oldMu_b = env.Mu_b
	}
	return []float64{0.0, 0.0, 0.0}, fmt.Errorf("failed to find D1/Mu_h/Mu_b solution for env=%s\n", env.String())
	/*
		system, start := D1Mu_hMu_bSystem(env)
		solution, err := solve.MultiDim(system, start, epsAbs, epsRel)
		if err != nil {
			return nil, err
		}
		return solution, nil
	*/
}