当前位置: 首页>>代码示例>>Golang>>正文


Golang GraphVars.X方法代码示例

本文整理汇总了Golang中github.com/tflovorn/scExplorer/plots.GraphVars.X方法的典型用法代码示例。如果您正苦于以下问题:Golang GraphVars.X方法的具体用法?Golang GraphVars.X怎么用?Golang GraphVars.X使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/tflovorn/scExplorer/plots.GraphVars的用法示例。


在下文中一共展示了GraphVars.X方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestPlotX2VsT

func TestPlotX2VsT(t *testing.T) {
	flag.Parse()
	if !(*testPlot || *longPlot) {
		return
	}
	var plotEnvs []interface{}
	var errs []error
	wd, _ := os.Getwd()
	cachePath := wd + "/__data_cache_tempLow"
	if *loadCache {
		var err error
		plotEnvs, errs, err = tempAll.LoadEnvCache(cachePath)
		if err != nil {
			t.Fatal(err)
		}
	} else {
		envs, err := lowDefaultEnvSet(*longPlot)
		if err != nil {
			t.Fatal(err)
		}
		// solve the full system
		eps := 1e-9
		plotEnvs, errs = tempAll.MultiSolve(envs, eps, eps, D1MuBetaSolve)
		// cache results for future use
		err = tempAll.SaveEnvCache(cachePath, plotEnvs, errs)
		if err != nil {
			t.Fatal(err)
		}
	}
	Xs := getXs(plotEnvs)
	// T vs F0 plots
	vars := plots.GraphVars{"F0", "", []string{"Tz", "Thp", "X", "Be_field"}, []string{"t_z", "t_h^{\\prime}", "x", "eB"}, nil, tempAll.GetTemp}
	fileLabel := "plot_data.T_F0"
	grapherPath := wd + "/../plots/grapher.py"
	graphParams := map[string]string{plots.FILE_KEY: wd + "/" + fileLabel, plots.XLABEL_KEY: "$F_0$", plots.YLABEL_KEY: "$T$"}
	err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
	if err != nil {
		t.Fatalf("error making T(F0) plot: %v", err)
	}
	// X2 vs T plots
	fileLabel = "plot_data.x2_T"
	graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
	graphParams[plots.XLABEL_KEY] = "$T$"
	graphParams[plots.YLABEL_KEY] = "$x_2$"
	vars.X = ""
	vars.XFunc = tempAll.GetTemp
	vars.YFunc = tempCrit.GetX2
	err = plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
	if err != nil {
		t.Fatalf("error making X2(T) plot: %v", err)
	}
	// Mu_h vs T plots
	fileLabel = "plot_data.mu_h_T"
	graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
	graphParams[plots.YLABEL_KEY] = "$\\mu_h$"
	vars.Y = "Mu_h"
	vars.YFunc = nil
	err = plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
	if err != nil {
		t.Fatalf("error making Mu_h(T) plot: %v", err)
	}
	// if looking for magnetization plot, make that plot and don't get Cv
	if *magnetization_calc {
		fileLabel = "plot_data.M_eB"
		graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
		graphParams[plots.XLABEL_KEY] = "$eB$"
		graphParams[plots.YLABEL_KEY] = "$M$"
		vars.X = "Be_field"
		vars.XFunc = nil
		vars.Y = ""
		vars.YFunc = tempCrit.GetMagnetization
		vars.Params = []string{"Tz", "Thp", "X", "F0"}
		vars.ParamLabels = []string{"t_z", "t_h^{\\prime}", "x", "F_0"}
		err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
		if err != nil {
			t.Fatalf("error making M plot: %v", err)
		}
		return
	}
	// calculate specific heat contributions
	SHenvs := make([]interface{}, len(plotEnvs))
	F := func(i int, cerr chan<- error) {
		pe := plotEnvs[i]
		if pe == nil {
			cerr <- errors.New("pe is nil")
			return
		}
		if errs[i] != nil {
			cerr <- errs[i]
			return
		}
		env, ok := pe.(tempAll.Environment)
		if !ok {
			cerr <- errors.New("pe is not Environment")
		}
		X2, err := tempCrit.X2(&env)
		if err != nil {
			cerr <- err
			return
		}
//.........这里部分代码省略.........
开发者ID:tflovorn,项目名称:scExplorer,代码行数:101,代码来源:system_test.go

示例2: TestPlotX2VsMu_b

func TestPlotX2VsMu_b(t *testing.T) {
	flag.Parse()
	if !(*testPlot || *longPlot) {
		return
	}
	var plotEnvs []interface{}
	var errs []error
	wd, _ := os.Getwd()
	cachePath := wd + "/__data_cache_tempFluc"
	if *loadCache {
		var err error
		plotEnvs, errs, err = tempAll.LoadEnvCache(cachePath)
		if err != nil {
			t.Fatal(err)
		}
	} else {
		envs, err := flucDefaultEnvSet(*longPlot)
		if err != nil {
			t.Fatal(err)
		}
		// solve the full system
		eps := 1e-9
		plotEnvs, errs = tempAll.MultiSolve(envs, eps, eps, FlucTempSolve)
		// cache results for future use
		err = tempAll.SaveEnvCache(cachePath, plotEnvs, errs)
		if err != nil {
			t.Fatal(err)
		}
	}
	Xs := getXs(plotEnvs)
	// T vs Mu_b plots
	vars := plots.GraphVars{"Mu_b", "", []string{"Tz", "Thp", "X", "Be_field"}, []string{"t_z", "t_h^{\\prime}", "x", "eB"}, nil, tempAll.GetTemp}
	fileLabel := "plot_data.T_mu_b"
	grapherPath := wd + "/../plots/grapher.py"
	graphParams := map[string]string{plots.FILE_KEY: wd + "/" + fileLabel, plots.XLABEL_KEY: "$\\mu_b$", plots.YLABEL_KEY: "$T$"}
	if !*skipPlots {
		err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
		if err != nil {
			t.Fatalf("error making T(Mu_b) plot: %v", err)
		}
	}
	// X2 vs T plots
	fileLabel = "plot_data.x2_T"
	graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
	graphParams[plots.XLABEL_KEY] = "$T$"
	graphParams[plots.YLABEL_KEY] = "$x_2$"
	vars.X = ""
	vars.XFunc = tempAll.GetTemp
	vars.YFunc = tempCrit.GetX2
	if !*skipPlots {
		err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
		if err != nil {
			t.Fatalf("error making X2(T) plot: %v", err)
		}
	}
	// Mu_h vs T plots
	fileLabel = "plot_data.mu_h_T"
	graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
	graphParams[plots.YLABEL_KEY] = "$\\mu_h$"
	vars.Y = "Mu_h"
	vars.YFunc = nil
	if !*skipPlots {
		err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
		if err != nil {
			t.Fatalf("error making Mu_h plot: %v", err)
		}
	}
	// omega(q) parameters (a, b) vs T
	get_fit := func(data interface{}, i int) float64 {
		env := data.(tempAll.Environment)
		if env.FixedPairCoeffs {
			if i == 0 || i == 1 {
				return env.A
			} else {
				return env.B
			}
		}
		fit, err := tempCrit.OmegaFit(&env, tempCrit.OmegaPlus)
		if err != nil {
			fmt.Printf("%v\n", err)
		}
		return fit[i]
	}
	get_a := func(data interface{}) float64 {
		return get_fit(data, 0)
	}
	get_b := func(data interface{}) float64 {
		return get_fit(data, 2)
	}
	fileLabel = "plot_data.a_T"
	graphParams[plots.FILE_KEY] = wd + "/" + fileLabel
	graphParams[plots.YLABEL_KEY] = "$a$"
	vars.Y = ""
	vars.YFunc = get_a
	if !*skipPlots {
		err := plots.MultiPlot(plotEnvs, errs, vars, graphParams, grapherPath)
		if err != nil {
			t.Fatalf("error making a plot: %v", err)
		}
	}
//.........这里部分代码省略.........
开发者ID:tflovorn,项目名称:scExplorer,代码行数:101,代码来源:system_test.go


注:本文中的github.com/tflovorn/scExplorer/plots.GraphVars.X方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。