本文整理汇总了Golang中github.com/cpmech/gosl/io.Pfyel函数的典型用法代码示例。如果您正苦于以下问题:Golang Pfyel函数的具体用法?Golang Pfyel怎么用?Golang Pfyel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pfyel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkinput
func checkinput(tst *testing.T, m *Mesh, nverts, ncells int, X [][]float64, vtags, ctags, parts []int, types []string, V [][]int, etags, ftags [][]int) {
if len(m.Verts) != nverts {
tst.Errorf("nverts is incorrect: %d != %d", len(m.Verts), nverts)
return
}
if len(m.Cells) != ncells {
tst.Errorf("ncells is incorrect: %d != %d", len(m.Cells), ncells)
return
}
io.Pfyel("\nvertices:\n")
for i, v := range m.Verts {
io.Pf("%+v\n", v)
chk.Vector(tst, io.Sf("vertex %2d: X", v.Id), 1e-15, v.X, X[v.Id])
if v.Tag != vtags[i] {
tst.Errorf("vtag is incorrect: %d != %d", v.Tag, vtags[i])
return
}
}
io.Pfyel("\ncells:\n")
for i, c := range m.Cells {
io.Pf("%+v\n", c)
if c.Tag != ctags[i] {
tst.Errorf("ctag is incorrect: %d != %d", c.Tag, ctags[i])
return
}
if c.Part != parts[i] {
tst.Errorf("part is incorrect: %d != %d", c.Part, parts[i])
return
}
chk.String(tst, types[i], c.Type)
chk.Ints(tst, io.Sf("cell %2d : V", c.Id), c.V, V[c.Id])
chk.Ints(tst, io.Sf("cell %2d : edgetags", c.Id), c.EdgeTags, etags[c.Id])
}
}
示例2: Test_ind01
func Test_ind01(tst *testing.T) {
//verbose()
chk.PrintTitle("ind01. representation and copying")
rnd.Init(0)
nbases := 3
A := get_individual(0, nbases)
B := A.GetCopy()
chk.Scalar(tst, "ova0", 1e-17, B.Ovas[0], 123)
chk.Scalar(tst, "ova1", 1e-17, B.Ovas[1], 345)
chk.Scalar(tst, "oor0", 1e-17, B.Oors[0], 10)
chk.Scalar(tst, "oor1", 1e-17, B.Oors[1], 20)
chk.Scalar(tst, "oor2", 1e-17, B.Oors[2], 30)
fmts := map[string][]string{"int": {" %d"}, "flt": {" %.1f"}, "str": {" %q"}, "key": {" %x"}, "byt": {" %q"}, "fun": {" %q"}}
oA := A.Output(fmts, false)
oB := B.Output(fmts, false)
io.Pfyel("\n%v\n", oA)
io.Pfyel("%v\n\n", oB)
chk.String(tst, oA, " 1 20 300 4.4 5.5 666.0 \"abc\" \"b\" \"c\" 53 47 41 \"ABC\" \"DEF\" \"GHI\" \"f0\" \"f1\" \"f2\"")
chk.String(tst, oB, " 1 20 300 4.4 5.5 666.0 \"abc\" \"b\" \"c\" 53 47 41 \"ABC\" \"DEF\" \"GHI\" \"f0\" \"f1\" \"f2\"")
A.SetFloat(1, 33)
A.SetFloat(2, 88)
oA = A.Output(fmts, false)
io.Pfyel("\n%v\n", oA)
chk.String(tst, oA, " 1 20 300 4.4 33.0 88.0 \"abc\" \"b\" \"c\" 53 47 41 \"ABC\" \"DEF\" \"GHI\" \"f0\" \"f1\" \"f2\"")
}
示例3: Test_stat02
func Test_stat02(tst *testing.T) {
//verbose()
chk.PrintTitle("stat02")
x := [][]float64{
{100, 100, 102, 98, 77, 99, 70, 105, 98},
{80, 101, 12, 58, 47, 80, 20, 111, 89},
{50, 130, 72, 38, 71, 15, 10, 12, 55},
}
y, z := StatTable(x, true, true)
la.PrintMat("x", x, "%5g", false)
la.PrintMat("y", y, "%13.6f", false)
la.PrintMat("z", z, "%13.6f", false)
io.Pforan("\nmin\n")
chk.Scalar(tst, "y00=min(x[0,:])", 1e-17, y[0][0], 70)
chk.Scalar(tst, "y01=min(x[1,:])", 1e-17, y[0][1], 12)
chk.Scalar(tst, "y02=min(x[2,:])", 1e-17, y[0][2], 10)
io.Pforan("\nave\n")
chk.Scalar(tst, "y10=ave(x[0,:])", 1e-17, y[1][0], 849.0/9.0)
chk.Scalar(tst, "y11=ave(x[1,:])", 1e-17, y[1][1], 598.0/9.0)
chk.Scalar(tst, "y12=ave(x[2,:])", 1e-17, y[1][2], 453.0/9.0)
io.Pforan("\nmax\n")
chk.Scalar(tst, "y20=max(x[0,:])", 1e-17, y[2][0], 105)
chk.Scalar(tst, "y21=max(x[1,:])", 1e-17, y[2][1], 111)
chk.Scalar(tst, "y22=max(x[2,:])", 1e-17, y[2][2], 130)
io.Pforan("\ndev\n")
chk.Scalar(tst, "y30=dev(x[0,:])", 1e-17, y[3][0], 12.134661099511597)
chk.Scalar(tst, "y31=dev(x[1,:])", 1e-17, y[3][1], 34.688294535444918)
chk.Scalar(tst, "y32=dev(x[2,:])", 1e-17, y[3][2], 38.343839140075687)
io.Pfyel("\nmin\n")
chk.Scalar(tst, "z00=min(y[0,:])=min(min)", 1e-17, z[0][0], 10)
chk.Scalar(tst, "z01=min(y[1,:])=min(ave)", 1e-17, z[0][1], 453.0/9.0)
chk.Scalar(tst, "z02=min(y[2,:])=min(max)", 1e-17, z[0][2], 105)
chk.Scalar(tst, "z03=min(y[3,:])=min(dev)", 1e-17, z[0][3], 12.134661099511597)
io.Pfyel("\nave\n")
chk.Scalar(tst, "z10=ave(y[0,:])=ave(min)", 1e-17, z[1][0], 92.0/3.0)
chk.Scalar(tst, "z11=ave(y[1,:])=ave(ave)", 1e-17, z[1][1], ((849.0+598.0+453.0)/9.0)/3.0)
chk.Scalar(tst, "z12=ave(y[2,:])=ave(max)", 1e-17, z[1][2], 346.0/3.0)
chk.Scalar(tst, "z13=ave(y[3,:])=ave(dev)", 1e-17, z[1][3], (12.134661099511597+34.688294535444918+38.343839140075687)/3.0)
io.Pfyel("\nmax\n")
chk.Scalar(tst, "z20=max(y[0,:])=max(min)", 1e-17, z[2][0], 70)
chk.Scalar(tst, "z21=max(y[1,:])=max(ave)", 1e-17, z[2][1], 849.0/9.0)
chk.Scalar(tst, "z22=max(y[2,:])=max(max)", 1e-17, z[2][2], 130)
chk.Scalar(tst, "z23=max(y[3,:])=max(dev)", 1e-17, z[2][3], 38.343839140075687)
io.Pfyel("\ndev\n")
chk.Scalar(tst, "z30=dev(y[0,:])=dev(min)", 1e-17, z[3][0], 34.078341117685483)
chk.Scalar(tst, "z31=dev(y[1,:])=dev(ave)", 1e-17, z[3][1], 22.261169573539771)
chk.Scalar(tst, "z32=dev(y[2,:])=dev(max)", 1e-17, z[3][2], 13.051181300301263)
chk.Scalar(tst, "z33=dev(y[3,:])=dev(dev)", 1e-17, z[3][3], 14.194778389023206)
}
示例4:
// CalcΔεElast calculates Δε corresponding to an elastic loading with Δp and Δq
func CalcΔεElast(Δε []float64, K, G float64, Δp, Δq float64, axsym bool) (Δεv, Δεd float64, err error) {
Δεv = -Δp / K
Δεd = Δq / (3.0 * G)
var Δεx, Δεy, Δεz float64
if axsym { // axisymmetric
compression := true
if compression {
Δεx = Δεv/3.0 + Δεd/2.0
Δεy = Δεx
Δεz = Δεv/3.0 - Δεd
} else {
Δεx = Δεv/3.0 - Δεd/2.0
Δεy = Δεv/3.0 + Δεd
Δεz = Δεx
}
} else { // plane-strain with Δεy = Δεx / 2
c := 9.0 * Δεd * Δεd / (4.0 * Δεv * Δεv)
α := 0.0
if math.Abs(c-1.0) > 1e-15 {
d := 3.0 * (4.0*c - 1.0)
if d < 0.0 {
return 0, 0, chk.Err("discriminant < 0: c=%v d=%v", c, d)
}
α1 := (1.0 + 2.0*c + math.Sqrt(d)) / (2.0 - 2.0*c)
α2 := (1.0 + 2.0*c - math.Sqrt(d)) / (2.0 - 2.0*c)
α = α1
io.Pfyel("d, α1, α2 = %v, %v, %v\n", d, α1, α2)
}
io.Pfyel("c, α = %v, %v\n", c, α)
Δεy = Δεv / (1.0 + α)
Δεx = α * Δεy
Δεz = 0
}
//io.Pfpink("Δp=%v, Δq=%v => Δεv=%v, Δεd=%v => Δεx=%v, Δεy=%v, Δεz=%v\n", Δp, Δq, Δεv, Δεd, Δεx, Δεy, Δεz)
Δε[0] = Δεx
Δε[1] = Δεy
Δε[2] = Δεz
Δε[3] = 0
Δεv_ := tsr.M_εv(Δε)
Δεd_ := tsr.M_εd(Δε)
if math.Abs(Δεv-Δεv_) > 1e-15 {
return 0, 0, chk.Err(_path_err09, Δεv, Δεv_)
}
if Δεd < 0 {
Δεd_ = -Δεd_ // allow negative values
}
if math.Abs(Δεd-Δεd_) > 1e-15 {
return 0, 0, chk.Err(_path_err10, Δεd, Δεd_)
}
return
}
示例5: Test_shp01
func Test_shp01(tst *testing.T) {
//verbose()
chk.PrintTitle("shp01")
r := []float64{0, 0, 0}
verb := true
for name, _ := range Functions {
io.Pfyel("--------------------------------- %-6s---------------------------------\n", name)
// check S
tol := 1e-17
if name == "tri10" {
tol = 1e-14
}
checkShape(tst, name, tol, verb)
// check dSdR
tol = 1e-14
if name == "lin5" || name == "lin4" || name == "tri10" || name == "qua12" || name == "qua16" {
tol = 1e-10
}
if name == "tri15" {
tol = 1e-9
}
checkDerivs(tst, name, r, tol, verb)
io.PfGreen("OK\n")
}
}
示例6: Test_MTint01
func Test_MTint01(tst *testing.T) {
//verbose()
chk.PrintTitle("MTint01. integers (Mersenne Twister)")
Init(1234)
nints := 10
vals := make([]int, NSAMPLES)
// using MTint
t0 := time.Now()
for i := 0; i < NSAMPLES; i++ {
vals[i] = MTint(0, nints-1)
}
io.Pforan("time elapsed = %v\n", time.Now().Sub(t0))
hist := IntHistogram{Stations: utl.IntRange(nints + 1)}
hist.Count(vals, true)
io.Pfyel(TextHist(hist.GenLabels("%d"), hist.Counts, 60))
// using MTints
t0 = time.Now()
MTints(vals, 0, nints-1)
io.Pforan("time elapsed = %v\n", time.Now().Sub(t0))
hist.Count(vals, true)
io.Pfcyan(TextHist(hist.GenLabels("%d"), hist.Counts, 60))
}
示例7: Test_imap
func Test_imap(tst *testing.T) {
//utl.Tsilent = false
chk.PrintTitle("Test imap")
for name, shape := range factory {
gndim := shape.Gndim
if gndim == 1 {
continue
}
io.Pfyel("--------------------------------- %-6s---------------------------------\n", name)
// check inverse mapping
tol := 1e-14
noise := 0.01
if name == "tri10" {
tol = 1e-14
}
if shape.FaceNvertsMax > 2 {
noise = 0.0
}
nverts := shape.Nverts
C := la.MatAlloc(gndim, nverts)
s := []float64{rand.Float64(), rand.Float64(), rand.Float64()} // scale factors
la.MatCopy(C, 1.0, shape.NatCoords)
_ = tol
io.Pf("nverts:%v\n", nverts)
io.Pf("gndim:%v\n", gndim)
for i := 0; i < gndim; i++ {
for j := 0; j < nverts; j++ {
C[i][j] *= s[i]
C[i][j] += noise * rand.Float64() // noise
}
}
r := make([]float64, 3)
x := make([]float64, 3)
R := la.MatAlloc(gndim, nverts)
for j := 0; j < nverts; j++ {
for i := 0; i < gndim; i++ {
x[i] = C[i][j]
}
err := shape.InvMap(r, x, C)
io.Pf("r:%v\n", r)
_ = err
for i := 0; i < gndim; i++ {
R[i][j] = r[i]
}
}
chk.Matrix(tst, "checking", tol, R, shape.NatCoords)
io.PfGreen("OK\n")
}
}
示例8: Test_out02
func Test_out02(tst *testing.T) {
// finalise analysis process and catch errors
defer func() {
if err := recover(); err != nil {
tst.Fail()
io.PfRed("ERROR: %v\n", err)
}
}()
// test title
//verbose()
chk.PrintTitle("out02")
// start simulation
processing := fem.NewFEM("data/twoqua4.sim", "", true, true, false, false, chk.Verbose, 0)
// run simulation
err := processing.Run()
if err != nil {
tst.Errorf("Run failed:\n%v", err)
return
}
// start post-processing
Start("data/twoqua4.sim", 0, 0)
// get second ip coordinates
xip := Ipoints[1].X
io.Pfcyan("xip = %v\n", xip)
// define points
Define("A", N{-1})
Define("ips", Along{{xip[0], 0}, {xip[0], 1}})
// load results
LoadResults(nil)
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
tolu := 1e-15
x := GetCoords("A")
ux := GetRes("ux", "A", 0)
uy := GetRes("uy", "A", 0)
io.Pforan("ux=%v uy=%v\n", ux, uy)
for j, t := range Times {
io.Pfyel("t=%g\n", t)
sol.CheckDispl(tst, t, []float64{ux[j], uy[j]}, x, tolu)
}
}
示例9: msg
// msg prints information on residuals
func (o *NlSolver) msg(typ string, it int, Ldx, fx_max float64, first, last bool) {
if first {
io.Pfpink("\n%4s%23s%23s\n", "it", "Ldx", "fx_max")
io.Pfpink("%4s%23s%23s\n", "", io.Sf("(%7.1e)", o.fnewt), io.Sf("(%7.1e)", o.ftol))
return
}
io.Pfyel("%4d%23.15e%23.15e\n", it, Ldx, fx_max)
if last {
io.Pfgrey(". . . converged with %s. nit=%d, nFeval=%d, nJeval=%d\n", typ, it, o.NFeval, o.NJeval)
}
}
示例10: PrintConstraints
// PrintConstraints prints violated or not constraints
func (o System) PrintConstraints(P []float64, Pdemand float64, full bool) {
sumP := 0.0
for i, g := range o.G {
if full {
io.Pfyel("P%d range error = %v\n", i, utl.GtePenalty(P[i], g.Pmin, 1)+utl.GtePenalty(g.Pmax, P[i], 1))
}
sumP += P[i]
}
Ploss := 0.0
io.Pf("balance error = %v\n", math.Abs(sumP-Pdemand-Ploss))
}
示例11: Test_nurbs02
func Test_nurbs02(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs02. square with initial stress. run")
// fem
analysis := NewFEM("data/nurbs02.sim", "", true, false, false, false, chk.Verbose, 0)
// run simulation
err := analysis.Run()
if err != nil {
tst.Errorf("Run failed\n%v", err)
return
}
// domain
dom := analysis.Domains[0]
e := dom.Elems[0].(*ElemU)
io.PfYel("fex = %v\n", e.fex)
io.PfYel("fey = %v\n", e.fey)
la.PrintMat("K", e.K, "%10.2f", false)
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH0", V: -20},
&fun.Prm{N: "qnV0", V: -20},
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
t := dom.Sol.T
tolu := 1e-16
for _, n := range dom.Nodes {
eqx := n.GetEq("ux")
eqy := n.GetEq("uy")
u := []float64{dom.Sol.Y[eqx], dom.Sol.Y[eqy]}
io.Pfyel("u = %v\n", u)
sol.CheckDispl(tst, t, u, n.Vert.C, tolu)
}
// check stresses
tols := 1e-13
for idx, ip := range e.IpsElem {
x := e.Cell.Shp.IpRealCoords(e.X, ip)
σ := e.States[idx].Sig
io.Pforan("σ = %v\n", σ)
sol.CheckStress(tst, t, σ, x, tols)
}
}
示例12: PrintMemStat
// PrintMemStat prints memory statistics
func PrintMemStat(msg string) {
var mem runtime.MemStats
runtime.ReadMemStats(&mem)
io.PfYel("%s\n", msg)
io.Pfyel("Alloc = %v [KB] %v [MB] %v [GB]\n", mem.Alloc/KBSIZE, mem.Alloc/MBSIZE, mem.Alloc/GBSIZE)
io.Pfyel("HeapAlloc = %v [KB] %v [MB] %v [GB]\n", mem.HeapAlloc/KBSIZE, mem.HeapAlloc/MBSIZE, mem.HeapAlloc/GBSIZE)
io.Pfyel("Sys = %v [KB] %v [MB] %v [GB]\n", mem.Sys/KBSIZE, mem.Sys/MBSIZE, mem.Sys/GBSIZE)
io.Pfyel("HeapSys = %v [KB] %v [MB] %v [GB]\n", mem.HeapSys/KBSIZE, mem.HeapSys/MBSIZE, mem.HeapSys/GBSIZE)
io.Pfyel("TotalAlloc = %v [KB] %v [MB] %v [GB]\n", mem.TotalAlloc/KBSIZE, mem.TotalAlloc/MBSIZE, mem.TotalAlloc/GBSIZE)
io.Pfyel("Mallocs = %v\n", mem.Mallocs)
io.Pfyel("Frees = %v\n", mem.Frees)
}
示例13: Test_nurbs03
func Test_nurbs03(tst *testing.T) {
//verbose()
chk.PrintTitle("nurbs03. ini stress free square")
// fem
analysis := NewFEM("data/nurbs03.sim", "", true, false, false, false, chk.Verbose, 0)
// run simulation
err := analysis.Run()
if err != nil {
tst.Errorf("Run failed\n%v", err)
return
}
// domain
dom := analysis.Domains[0]
// element
e := dom.Elems[0].(*ElemU)
io.PfYel("fex = %v\n", e.fex)
io.PfYel("fey = %v\n", e.fey)
la.PrintMat("K", e.K, "%10.2f", false)
// solution
var sol ana.CteStressPstrain
sol.Init(fun.Prms{
&fun.Prm{N: "qnH", V: -50},
&fun.Prm{N: "qnV", V: -100},
})
// check displacements
t := dom.Sol.T
tolu := 1e-16
for _, n := range dom.Nodes {
eqx := n.GetEq("ux")
eqy := n.GetEq("uy")
u := []float64{dom.Sol.Y[eqx], dom.Sol.Y[eqy]}
io.Pfyel("u = %v\n", u)
sol.CheckDispl(tst, t, u, n.Vert.C, tolu)
}
}
示例14: Test_eigenp01
func Test_eigenp01(tst *testing.T) {
//verbose()
chk.PrintTitle("eigenp01")
// constants
tolP := 1e-14 // eigenprojectors
tolS := 1e-13 // spectral decomposition
toldP := 1e-9 // derivatives of eigenprojectors
ver := chk.Verbose // check P verbose
verdP := chk.Verbose // check dPda verbose
// run test
nd := test_nd
for idxA := 0; idxA < len(test_nd); idxA++ {
//for idxA := 10; idxA < 11; idxA++ {
//for idxA := 11; idxA < 12; idxA++ {
//for idxA := 12; idxA < 13; idxA++ {
// tensor and eigenvalues
A := test_AA[idxA]
a := M_Alloc2(nd[idxA])
Ten2Man(a, A)
io.PfYel("\n\ntst # %d ###################################################################################\n", idxA)
io.Pfblue2("a = %v\n", a)
io.Pfblue2("λ = %v\n", test_λ[idxA])
// check eigenprojectors
io.Pforan("\neigenprojectors\n")
λsorted := CheckEigenprojs(a, tolP, tolS, ver)
io.Pfyel("λsorted = %v\n", λsorted)
λchk := utl.DblGetSorted(test_λ[idxA])
chk.Vector(tst, "λchk", 1e-12, λsorted, λchk)
// check derivatives of eigenprojectors
io.Pforan("\nderivatives\n")
CheckEigenprojsDerivs(a, toldP, verdP, EV_ZERO)
}
}
示例15: Test_GOshuffleInts01
func Test_GOshuffleInts01(tst *testing.T) {
//verbose()
chk.PrintTitle("GOshuffleInts01")
Init(0)
n := 10
nums := utl.IntRange(n)
io.Pfgreen("before = %v\n", nums)
IntShuffle(nums)
io.Pfcyan("after = %v\n", nums)
sort.Ints(nums)
io.Pforan("sorted = %v\n", nums)
chk.Ints(tst, "nums", nums, utl.IntRange(n))
shufled := IntGetShuffled(nums)
io.Pfyel("shufled = %v\n", shufled)
sort.Ints(shufled)
chk.Ints(tst, "shufled", shufled, utl.IntRange(n))
}