• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang plt.SetForPng函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cpmech/gosl/plt.SetForPng函数的典型用法代码示例。如果您正苦于以下问题:Golang SetForPng函数的具体用法?Golang SetForPng怎么用?Golang SetForPng使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Test_fun08

func Test_fun08(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun08. exc2")

	fun, err := New("exc2", []*Prm{
		&Prm{N: "ta", V: 5},
		&Prm{N: "a", V: 3},
		&Prm{N: "b", V: 0.2},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 7.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "exc2.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:29,代码来源:t_fun_test.go


示例2: Test_fun10

func Test_fun10(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun10. rmp")

	fun, err := New("rmp", []*Prm{
		&Prm{N: "ta", V: 1},
		&Prm{N: "tb", V: 2},
		&Prm{N: "ca", V: 0.5},
		&Prm{N: "cb", V: -1.5},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 3.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "rmp.png", tmin, tmax, xcte, 4, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-12
	dtol2 := 1e-17
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:30,代码来源:t_fun_test.go


示例3: Test_fun06c

func Test_fun06c(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun06c. pts")

	fun, err := New("pts", []*Prm{
		// T =                     0 0.05 0.1 0.2 0.3 0.5  0.75 1
		&Prm{N: "y=dt", Extra: "0.05 0.05 0.1 0.1 0.2 0.25 0.25 0"},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 1.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "ptsC.png", tmin, tmax, xcte, 8, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	tmin = 0.01
	tmax = 0.99
	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 10, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:30,代码来源:t_fun_test.go


示例4: Test_fun06b

func Test_fun06b(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun06b. pts")

	fun, err := New("pts", []*Prm{
		&Prm{N: "t0", V: 0.0}, {N: "y0", V: 0.50},
		&Prm{N: "dy", Extra: "-0.3  0  -0.15  -0.04  -0.01"},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 1.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "ptsB.png", tmin, tmax, xcte, 8, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	tmin = 0.01
	tmax = 0.99
	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:30,代码来源:t_fun_test.go


示例5: Test_fun06a

func Test_fun06a(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun06a. pts")

	fun, err := New("pts", []*Prm{
		&Prm{N: "t", V: 0.00}, {N: "y", V: 0.50},
		&Prm{N: "t", V: 1.00}, {N: "y", V: 0.20},
		&Prm{N: "t", V: 2.00}, {N: "y", V: 0.20},
		&Prm{N: "t", V: 3.00}, {N: "y", V: 0.05},
		&Prm{N: "t", V: 4.00}, {N: "y", V: 0.01},
		&Prm{N: "t", V: 5.00}, {N: "y", V: 0.00},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := -1.0
	tmax := 6.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "pts.png", tmin, tmax, xcte, 8, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	tmin = 0.01
	tmax = 4.99
	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:34,代码来源:t_fun_test.go


示例6: Test_fun11

func Test_fun11(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun11. ref-inc-rl1")

	fun, err := New("ref-inc-rl1", []*Prm{
		&Prm{N: "lam0", V: 0.001},
		&Prm{N: "lam1", V: 1.2},
		&Prm{N: "alp", V: 0.01},
		&Prm{N: "bet", V: 10},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 1.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "ref-inc-rl1.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:30,代码来源:t_fun_test.go


示例7: Test_fun13

func Test_fun13(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun13. pulse")

	pulse, err := New("pulse", []*Prm{
		&Prm{N: "ca", V: 0.2},
		&Prm{N: "cb", V: 2.0},
		&Prm{N: "ta", V: 1.0},
		&Prm{N: "tb", V: 2.5},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 5.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(pulse, "/tmp/gosl/fun", "pulse.png", tmin, tmax, xcte, 61, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-17
	dtol := 1e-10
	dtol2 := 1e-10
	ver := chk.Verbose
	tskip := []float64{1, 4}
	CheckDerivT(tst, pulse, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:31,代码来源:t_fun_test.go


示例8: main

func main() {

	// options
	verbose := false

	// start analysis process
	out.Start("spo754.sim", 0, 0)

	// all nodes
	out.Define("all nodes", out.AllNodes())
	out.Define("A", out.At{0, 5})

	// load results
	out.LoadResults(nil)

	// check
	skipK := true
	tolK := 1e-17
	tolu := 1e-11
	tols := 1e-04

	var tst testing.T
	fem.TestingCompareResultsU(&tst, "spo754.sim", "spo754.cmp", "", tolK, tolu, tols, skipK, verbose)

	// save
	plt.SetForPng(0.8, 400, 200)
	out.Splot("Plot")
	out.Plot("uy", "t", "A", plt.Fmt{C: "r", M: "o"}, -1)
	out.Draw("/tmp", "spo754.png", false, nil)
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:30,代码来源:doplot.go


示例9: PlotTwoNurbs

// PlotTwoNurbs plots two NURBS for comparison
func PlotTwoNurbs(dirout, fn string, b, c *Nurbs, npts int, ids bool, extra func()) {
	plt.Reset()
	if io.FnExt(fn) == ".eps" {
		plt.SetForEps(1.5, 500)
	} else {
		plt.SetForPng(1.5, 500, 150)
	}

	plt.Subplot(3, 1, 1)
	b.DrawCtrl2d(ids, "", "")
	b.DrawElems2d(npts, ids, "", "")
	if extra != nil {
		extra()
	}
	plt.Equal()

	plt.Subplot(3, 1, 2)
	c.DrawCtrl2d(ids, "", "")
	c.DrawElems2d(npts, ids, "", "")
	plt.Equal()

	plt.Subplot(3, 1, 3)
	b.DrawElems2d(npts, ids, ", lw=3", "")
	c.DrawElems2d(npts, ids, ", color='red', marker='+', markevery=10", "color='green', size=7, va='bottom'")
	plt.Equal()

	plt.SaveD(dirout, fn)
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:29,代码来源:plotnurbs.go


示例10: Test_fun16

func Test_fun16(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun16. cut-sin; test cut negative values.")

	fun, err := New("cut-sin", []*Prm{
		&Prm{N: "a", V: 10},
		&Prm{N: "b", V: math.Pi},
		&Prm{N: "c", V: 1.0},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 2.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(fun, "/tmp/gosl/fun", "cut-sin-negative.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-8
	dtol2 := 1e-7
	ver := chk.Verbose
	CheckDerivT(tst, fun, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:29,代码来源:t_fun_test.go


示例11: Test_tri01

func Test_tri01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("tri01")

	V := [][]float64{
		{0.0, 0.0},
		{1.0, 0.0},
		{1.0, 1.0},
		{0.0, 1.0},
		{0.5, 0.5},
	}

	C := [][]int{
		{0, 1, 4},
		{1, 2, 4},
		{2, 3, 4},
		{3, 0, 4},
	}

	if chk.Verbose {
		plt.SetForPng(1, 300, 150)
		Draw(V, C, nil)
		plt.Equal()
		plt.AxisRange(-0.1, 1.1, -0.1, 1.1)
		plt.Gll("x", "y", "")
		plt.SaveD("/tmp/gosl/tri", "tri01.png")
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:29,代码来源:t_tri_test.go


示例12: main

func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "sg111", ".sim", true)

	// results
	out.Start(filename, 0, 0)
	out.Define("tip", out.N{1})
	out.LoadResults(nil)

	// plot FEM results
	out.Plot("t", "uy", "tip", plt.Fmt{C: "r", Ls: "None", M: ".", L: "gofem"}, -1)

	// analytical solution
	tAna := utl.LinSpace(0, 5, 101)
	uyAna := make([]float64, len(tAna))
	for i, t := range tAna {
		uyAna[i] = solution_uy(t, 1.0)
	}

	// save
	plt.SetForPng(0.8, 400, 200)
	out.Draw("/tmp", fnkey+".png", false, func(i, j, n int) {
		plt.Plot(tAna, uyAna, "'g-', clip_on=0, label='analytical'")
	})
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:26,代码来源:doplot-sg111.go


示例13: main

func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "sg111", ".sim", true)

	// fem
	if !fem.Start(filename, false, false, false) {
		io.PfRed("Start failed\n")
		return
	}
	dom, sum, ok := fem.AllocSetAndInit(0, true, true)
	if !ok {
		io.PfRed("AllocSetAndInit failed\n")
		return
	}

	// selected node and dof index
	nidx := 1
	didx := 1

	// gofem
	ntout := len(sum.OutTimes)
	uy := make([]float64, ntout)
	for tidx, _ := range sum.OutTimes {

		// read results from file
		if !dom.In(sum, tidx, true) {
			io.PfRed("plot_spo751: cannot read solution\n")
			return
		}

		// collect results for load versus time plot
		nod := dom.Nodes[nidx]
		eq := nod.Dofs[didx].Eq
		uy[tidx] = dom.Sol.Y[eq]

		// check
		if math.Abs(dom.Sol.T-sum.OutTimes[tidx]) > 1e-14 {
			io.PfRed("output times do not match time in solution array\n")
			return
		}
	}

	// plot fem results
	plt.SetForPng(0.8, 400, 200)
	plt.Plot(sum.OutTimes, uy, "'ro-', clip_on=0, label='gofem'")

	// analytical solution
	tAna := utl.LinSpace(0, 5, 101)
	uyAna := make([]float64, len(tAna))
	for i, t := range tAna {
		uyAna[i] = solution_uy(t, 1.0)
	}
	plt.Plot(tAna, uyAna, "'g-', clip_on=0, label='analytical'")

	// save
	plt.Gll("$t$", "$u_y$", "")
	plt.SaveD("/tmp", fnkey+".png")
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:59,代码来源:doplot-sg111-notUsingOut.go


示例14: main

func main() {

	// input data
	fn, fnk := io.ArgToFilename(0, "nurbs01", ".msh", true)
	ctrl := io.ArgToBool(1, true)
	ids := io.ArgToBool(2, true)
	useminmax := io.ArgToBool(3, false)
	axisequal := io.ArgToBool(4, true)
	xmin := io.ArgToFloat(5, 0)
	xmax := io.ArgToFloat(6, 0)
	ymin := io.ArgToFloat(7, 0)
	ymax := io.ArgToFloat(8, 0)
	eps := io.ArgToBool(9, false)
	npts := io.ArgToInt(10, 41)

	// print input table
	io.Pf("\n%s\n", io.ArgsTable("INPUT ARGUMENTS",
		"mesh filename", "fn", fn,
		"show control points", "ctrl", ctrl,
		"show ids", "ids", ids,
		"use xmin,xmax,ymin,ymax", "useminmax", useminmax,
		"enforce axis.equal", "axisequal", axisequal,
		"min(x)", "xmin", xmin,
		"max(x)", "xmax", xmax,
		"min(y)", "ymin", ymin,
		"max(y)", "ymax", ymax,
		"generate eps instead of png", "eps", eps,
		"number of divisions", "npts", npts,
	))

	// load nurbss
	B := gm.ReadMsh(fnk)

	// plot
	if eps {
		plt.SetForEps(0.75, 500)
	} else {
		plt.SetForPng(0.75, 500, 150)
	}
	for _, b := range B {
		if ctrl {
			b.DrawCtrl2d(ids, "", "")
		}
		b.DrawElems2d(npts, ids, "", "")
	}
	if axisequal {
		plt.Equal()
	}
	if useminmax {
		plt.AxisRange(xmin, xmax, ymin, ymax)
	}
	ext := ".png"
	if eps {
		ext = ".eps"
	}
	plt.Save(fnk + ext)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:57,代码来源:NurbsDraw.go


示例15: Test_bspline01

func Test_bspline01(tst *testing.T) {

	//verbose()
	chk.PrintTitle("bspline01")

	var s1 Bspline
	T1 := []float64{0, 0, 0, 1, 1, 1}
	s1.Init(T1, 2)
	s1.SetControl([][]float64{{0, 0}, {0.5, 1}, {1, 0}})

	var s2 Bspline
	T2 := []float64{0, 0, 0, 0.5, 1, 1, 1}
	s2.Init(T2, 2)
	s2.SetControl([][]float64{{0, 0}, {0.25, 0.5}, {0.75, 0.5}, {1, 0}})

	if chk.Verbose {
		npts := 201
		plt.SetForPng(1.5, 600, 150)
		plt.SplotGap(0.2, 0.4)

		str0 := ",lw=2"
		str1 := ",ls='none',marker='+',color='cyan',markevery=10"
		str2 := ",ls='none',marker='x',markevery=10"
		str3 := ",ls='none',marker='+',markevery=10"
		str4 := ",ls='none',marker='4',markevery=10"

		plt.Subplot(3, 2, 1)
		s1.Draw2d(str0, "", npts, 0) // 0 => CalcBasis
		s1.Draw2d(str1, "", npts, 1) // 1 => RecursiveBasis

		plt.Subplot(3, 2, 2)
		plt.SetAxis(0, 1, 0, 1)
		s2.Draw2d(str0, "", npts, 0) // 0 => CalcBasis
		s2.Draw2d(str1, "", npts, 1) // 1 => RecursiveBasis

		plt.Subplot(3, 2, 3)
		s1.PlotBasis("", npts, 0)   // 0 => CalcBasis
		s1.PlotBasis(str2, npts, 1) // 1 => CalcBasisAndDerivs
		s1.PlotBasis(str3, npts, 2) // 2 => RecursiveBasis

		plt.Subplot(3, 2, 4)
		s2.PlotBasis("", npts, 0)   // 0 => CalcBasis
		s2.PlotBasis(str2, npts, 1) // 1 => CalcBasisAndDerivs
		s2.PlotBasis(str3, npts, 2) // 2 => RecursiveBasis

		plt.Subplot(3, 2, 5)
		s1.PlotDerivs("", npts, 0)   // 0 => CalcBasisAndDerivs
		s1.PlotDerivs(str4, npts, 1) // 1 => NumericalDeriv

		plt.Subplot(3, 2, 6)
		s2.PlotDerivs("", npts, 0)   // 0 => CalcBasisAndDerivs
		s2.PlotDerivs(str4, npts, 1) // 1 => NumericalDeriv

		plt.SaveD("/tmp/gosl/gm", "bspline01.png")
	}
}
开发者ID:PaddySchmidt,项目名称:gosl,代码行数:56,代码来源:t_bspline_test.go


示例16: Test_fun03

func Test_fun03(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun03. add, cte, srmps")

	cte, err := New("cte", []*Prm{&Prm{N: "c", V: 30}})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	srmps, err := New("srmps", []*Prm{
		&Prm{N: "ca", V: 0},
		&Prm{N: "cb", V: 1},
		&Prm{N: "ta", V: 0},
		&Prm{N: "tb", V: 1},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	add, err := New("add", []*Prm{
		&Prm{N: "a", V: 1},
		&Prm{N: "b", V: 1},
		&Prm{N: "fa", Fcn: cte},
		&Prm{N: "fb", Fcn: srmps},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 1.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(cte, "/tmp/gosl/fun", "cte.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
		plt.Clf()
		PlotT(srmps, "/tmp/gosl/fun", "srmps.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
		plt.Clf()
		PlotT(add, "/tmp/gosl/fun", "add.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-10
	dtol2 := 1e-9
	ver := chk.Verbose
	tskip := []float64{tmin, tmax}
	CheckDerivT(tst, cte, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
	io.Pf("\n")
	CheckDerivT(tst, srmps, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
	io.Pf("\n")
	CheckDerivT(tst, add, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:56,代码来源:t_fun_test.go


示例17: Test_fun12

func Test_fun12(tst *testing.T) {

	//verbose()
	chk.PrintTitle("fun12. mul")

	cos, err := New("cos", []*Prm{
		&Prm{N: "a", V: 1},
		&Prm{N: "b/pi", V: 2},
		&Prm{N: "c", V: 1},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	lin, err := New("lin", []*Prm{
		&Prm{N: "m", V: 0.5},
		&Prm{N: "ts", V: 0},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	mul, err := New("mul", []*Prm{
		&Prm{N: "fa", Fcn: cos},
		&Prm{N: "fb", Fcn: lin},
	})
	if err != nil {
		tst.Errorf("test failed: %v\n", err)
		return
	}

	tmin := 0.0
	tmax := 1.0
	xcte := []float64{0, 0, 0}
	if chk.Verbose {
		plt.SetForPng(1.2, 400, 150)
		PlotT(cos, "/tmp/gosl/fun", "cosB.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
		plt.Clf()
		PlotT(lin, "/tmp/gosl/fun", "linB.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
		plt.Clf()
		PlotT(mul, "/tmp/gosl/fun", "mul.png", tmin, tmax, xcte, 41, "", "", "", "", "label='f'", "label='g'", "label='h'")
	}

	sktol := 1e-10
	dtol := 1e-9
	dtol2 := 1e-8
	ver := chk.Verbose
	tskip := []float64{tmin, tmax}
	CheckDerivT(tst, cos, tmin, tmax, xcte, 11, nil, sktol, dtol, dtol2, ver)
	io.Pf("\n")
	CheckDerivT(tst, lin, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
	io.Pf("\n")
	CheckDerivT(tst, mul, tmin, tmax, xcte, 11, tskip, sktol, dtol, dtol2, ver)
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:56,代码来源:t_fun_test.go


示例18: Test_bins02

func Test_bins02(tst *testing.T) {

	//verbose()
	chk.PrintTitle("bins02. find along line (2D)")

	// bins
	var bins Bins
	bins.Init([]float64{-0.2, -0.2}, []float64{0.8, 1.8}, 5)

	// fill bins structure
	maxit := 5 // number of entries
	ID := make([]int, maxit)
	for k := 0; k < maxit; k++ {
		x := float64(k) / float64(maxit)
		ID[k] = k
		err := bins.Append([]float64{x, 2*x + 0.2}, ID[k])
		if err != nil {
			chk.Panic(err.Error())
		}
	}

	// add more points to bins
	for i := 0; i < 5; i++ {
		err := bins.Append([]float64{float64(i) * 0.1, 1.8}, 100+i)
		if err != nil {
			chk.Panic(err.Error())
		}
	}

	// message
	for _, bin := range bins.All {
		if bin != nil {
			io.Pf("%v\n", bin)
		}
	}

	// find points along diagonal
	ids := bins.FindAlongSegment([]float64{0.0, 0.2}, []float64{0.8, 1.8}, 1e-8)
	io.Pforan("ids = %v\n", ids)
	chk.Ints(tst, "ids", ids, ID)

	// find additional points
	ids = bins.FindAlongSegment([]float64{-0.2, 1.8}, []float64{0.8, 1.8}, 1e-8)
	io.Pfcyan("ids = %v\n", ids)
	chk.Ints(tst, "ids", ids, []int{100, 101, 102, 103, 104, 4})

	// draw
	if chk.Verbose {
		plt.SetForPng(1, 500, 150)
		bins.Draw2d(true, true, true, true, map[int]bool{8: true, 9: true, 10: true})
		plt.SetXnticks(15)
		plt.SetYnticks(15)
		plt.SaveD("/tmp/gosl/gm", "test_bins02.png")
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:55,代码来源:t_search_test.go


示例19: main

func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "rjoint01", ".sim", true)

	// fem
	if !fem.Start(filename, false, false, false) {
		io.PfRed("Start failed\n")
		return
	}
	dom, sum, ok := fem.AllocSetAndInit(0, true, true)
	if !ok {
		io.PfRed("AllocSetAndInit failed\n")
		return
	}

	// rjoint element
	eid := 2
	ele := dom.Elems[eid].(*fem.Rjoint)
	ipd := ele.OutIpsData()

	// load results from file
	n := len(sum.OutTimes)
	mtau0 := make([]float64, n)
	mtau1 := make([]float64, n)
	mtau2 := make([]float64, n)
	ompb0 := make([]float64, n)
	ompb1 := make([]float64, n)
	ompb2 := make([]float64, n)
	for i, _ := range sum.OutTimes {
		if !dom.In(sum, i, true) {
			io.PfRed("cannot read solution\n")
			return
		}
		res0 := ipd[0].Calc(dom.Sol)
		res1 := ipd[1].Calc(dom.Sol)
		res2 := ipd[2].Calc(dom.Sol)
		mtau0[i] = -res0["tau"]
		mtau1[i] = -res1["tau"]
		mtau2[i] = -res2["tau"]
		ompb0[i] = res0["ompb"]
		ompb1[i] = res1["ompb"]
		ompb2[i] = res2["ompb"]
	}

	// plot
	plt.SetForPng(0.8, 400, 200)
	plt.Plot(ompb0, mtau0, "'r-', marker='.', label='p0', clip_on=0")
	plt.Plot(ompb1, mtau1, "'g-', marker='.', label='p1', clip_on=0")
	plt.Plot(ompb2, mtau2, "'b-', marker='.', label='p2', clip_on=0")
	plt.Gll("$\\bar{\\omega}_p$", "$-\\tau$", "")
	plt.SaveD("/tmp", fnkey+".png")
}
开发者ID:PaddySchmidt,项目名称:gofem,代码行数:53,代码来源:doplot-notUsingOut.go


示例20: Test_invs05

func Test_invs05(tst *testing.T) {

	//verbose()
	chk.PrintTitle("invs05")

	if SAVEPLOT {
		plt.Reset()
		plt.SetForPng(1, 500, 125)
		PlotRosette(1.1, true, true, true, 7)
	}

	addtoplot := func(σa, σb float64, σ []float64) {
		plt.PlotOne(σa, σb, "'ro', ms=5")
		plt.Text(σa, σb, io.Sf("$\\sigma_{123}=(%g,%g,%g)$", σ[0], σ[1], σ[2]), "size=8")
	}

	dotest := func(σ []float64, σacor, σbcor, σccor, θcor, tolσ float64) {
		w := M_w(σ)
		θ2 := math.Asin(w) * 180.0 / (3.0 * math.Pi)
		θ3 := M_θ(σ)
		σa, σb, σc := L2O(σ[0], σ[1], σ[2])
		σ0, σ1, σ2 := O2L(σa, σb, σc)
		σI, σA := make([]float64, 3), []float64{σa, σb, σc}
		la.MatVecMul(σI, 1, O2Lmat(), σA) // σI := L * σA
		io.Pf("σa σb σc = %v %v %v\n", σa, σb, σc)
		io.Pf("w        = %v\n", w)
		io.Pf("θ2, θ3   = %v, %v\n", θ2, θ3)
		chk.Scalar(tst, "σa", 1e-17, σa, σacor)
		chk.Scalar(tst, "σb", 1e-17, σb, σbcor)
		chk.Scalar(tst, "σc", 1e-17, σc, σccor)
		chk.Scalar(tst, "σ0", tolσ, σ0, σ[0])
		chk.Scalar(tst, "σ1", tolσ, σ1, σ[1])
		chk.Scalar(tst, "σ2", tolσ, σ2, σ[2])
		chk.Scalar(tst, "σI0", tolσ, σI[0], σ[0])
		chk.Scalar(tst, "σI1", tolσ, σI[1], σ[1])
		chk.Scalar(tst, "σI2", tolσ, σI[2], σ[2])
		chk.Scalar(tst, "θ2", 1e-6, θ2, θcor)
		chk.Scalar(tst, "θ3", 1e-17, θ3, θ2)
		addtoplot(σa, σb, σ)
	}

	dotest([]float64{-1, 0, 0, 0}, 0, 2.0/SQ6, 1.0/SQ3, 30, 1e-15)
	dotest([]float64{0, -1, 0, 0}, 1.0/SQ2, -1.0/SQ6, 1.0/SQ3, 30, 1e-15)
	dotest([]float64{0, 0, -1, 0}, -1.0/SQ2, -1.0/SQ6, 1.0/SQ3, 30, 1e-15)

	if SAVEPLOT {
		plt.Gll("$\\sigma_a$", "$\\sigma_b$", "")
		plt.Equal()
		plt.SaveD("/tmp/gosl", "fig_invs05.png")
	}
}
开发者ID:yunpeng1,项目名称:gosl,代码行数:51,代码来源:t_invariants_test.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang plt.Subplot函数代码示例发布时间:2022-05-23
下一篇:
Golang plt.SetForEps函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap