本文整理匯總了Golang中github.com/cpmech/gosl/plt.SetForPng函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetForPng函數的具體用法?Golang SetForPng怎麽用?Golang SetForPng使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetForPng函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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")
}
}
示例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'")
})
}
示例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")
}
示例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)
}
示例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")
}
}