Exemple #1
0
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)
}
Exemple #2
0
func main() {
	// options
	verbose := false
	show := true

	// finalise analysis process and catch errors upon exit
	defer out.End()

	// 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, "data/spo754.sim", "spo754.cmp", tolK, tolu, tols, skipK, verbose)

	// plot
	out.Splot("Plot")
	out.Plot("uy", "t", "A", plt.Fmt{C: "r", M: "o"}, -1)
	out.Draw("", "", show, nil)
}
Exemple #3
0
func main() {

	// finalise analysis process and catch errors
	defer out.End()

	// input data
	simfn := "onepulse-qua9co.sim"
	flag.Parse()
	if len(flag.Args()) > 0 {
		simfn = flag.Arg(0)
	}
	if io.FnExt(simfn) == "" {
		simfn += ".sim"
	}

	// start analysis process
	out.Start(simfn, 0, 0)

	// define entities
	out.Define("A B C D E", out.N{-5, -4, -3, -2, -1})
	out.Define("a b c d e", out.P{{15, 8}, {13, 8}, {8, 8}, {4, 8}, {0, 0}})

	// load results
	out.LoadResults(nil)

	// styles
	me := 10
	S := []plt.Fmt{
		plt.Fmt{C: "b", M: "*", Me: me},
		plt.Fmt{C: "g", M: "o", Me: me},
		plt.Fmt{C: "m", M: "x", Me: me},
		plt.Fmt{C: "orange", M: "+", Me: me},
		plt.Fmt{C: "r", M: "^", Me: me},
	}

	// pl
	out.Splot("liquid pressure")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "pl", l, S[i], -1)
	}

	// uy
	out.Splot("displacements")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "uy", l, S[i], -1)
	}

	out.Splot("liquid saturation")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sl", l, S[i], -1)
	}

	out.Splot("stresses")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sy", l, S[i], -1)
	}

	// show
	out.Draw("", "", true, nil)
}
Exemple #4
0
func main() {

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

	// results
	out.Start(filename, 0, 0)
	out.Define("p0", out.P{{-3, 0}}) // -3=tag, first ip
	out.Define("p1", out.P{{-3, 1}}) // -3=tag, second ip
	out.Define("p2", out.P{{-3, 2}}) // -3=tag, third ip
	out.LoadResults(nil)
	mtau0 := out.GetRes("tau", "p0", -1)
	mtau1 := out.GetRes("tau", "p1", -1)
	mtau2 := out.GetRes("tau", "p2", -1)
	for i := 0; i < len(out.Times); i++ {
		mtau0[i] *= -1
		mtau1[i] *= -1
		mtau2[i] *= -1
	}

	// plot FEM results
	out.Plot("ompb", mtau0, "p0", plt.Fmt{C: "r", Ls: "-", M: "."}, -1)
	out.Plot("ompb", mtau1, "p1", plt.Fmt{C: "g", Ls: "-", M: "."}, -1)
	out.Plot("ompb", mtau2, "p2", plt.Fmt{C: "b", Ls: "-", M: "."}, -1)
	out.Csplot.Ylbl = "$-\\tau$"

	// save
	plt.SetForPng(0.8, 400, 200)
	out.Draw("/tmp", fnkey+".png", false, nil)
}
Exemple #5
0
func main() {

	// input data
	simfn := "onepulse-qua9co.sim"
	flag.Parse()
	if len(flag.Args()) > 0 {
		simfn = flag.Arg(0)
	}
	if io.FnExt(simfn) == "" {
		simfn += ".sim"
	}

	// start analysis process
	out.Start(simfn, 0, 0)

	// define entities
	out.Define("A C E", out.N{-5, -3, -1})
	out.Define("a b", out.P{{1, 8}, {0, 8}})

	// load results
	out.LoadResults(nil)

	// styles
	me := 10
	Sn := []plt.Fmt{
		plt.Fmt{C: "b", M: "*", Me: me},
		plt.Fmt{C: "m", M: "x", Me: me},
		plt.Fmt{C: "r", M: "^", Me: me},
	}
	Se := []plt.Fmt{
		plt.Fmt{C: "b", M: "*", Me: me},
		plt.Fmt{C: "g", M: "o", Me: me},
	}

	// pl
	out.Splot("liquid pressure")
	for i, l := range []string{"A", "C", "E"} {
		out.Plot("t", "pl", l, Sn[i], -1)
	}

	// uy
	out.Splot("displacements")
	for i, l := range []string{"A", "C", "E"} {
		out.Plot("t", "uy", l, Sn[i], -1)
	}

	out.Splot("liquid saturation")
	for i, l := range []string{"a", "b"} {
		out.Plot("t", "sl", l, Se[i], -1)
	}

	out.Splot("stresses")
	for i, l := range []string{"a", "b"} {
		out.Plot("t", "sy", l, Se[i], -1)
	}

	// show
	out.Draw("", "", true, nil)
}
Exemple #6
0
func main() {

	// finalise analysis process and catch errors
	defer out.End()

	// input data
	simfn := "d2-simple-flux"
	flag.Parse()
	if len(flag.Args()) > 0 {
		simfn = flag.Arg(0)
	}
	if io.FnExt(simfn) == "" {
		simfn += ".sim"
	}

	// start analysis process
	out.Extrap = []string{"nwlx", "nwly"}
	out.Start(simfn, 0, 0)

	// define entities
	out.Define("top-middle", out.At{5, 3})
	out.Define("section-A", out.N{-1})
	out.Define("section-B", out.Along{{0, 0}, {10, 0}})

	// load results
	out.LoadResults(nil)

	// compute water discharge along section-A
	nwlx_TM := out.GetRes("ex_nwlx", "top-middle", -1)
	Q := out.Integrate("ex_nwlx", "section-A", "y", -1)
	io.PfYel("Q = %g m³/s [answer: 0.0003]\n", Q)

	// plot
	kt := len(out.Times) - 1
	out.Splot("")
	out.Plot("pl", "y", "section-A", plt.Fmt{L: "t=0"}, 0)
	out.Plot("pl", "y", "section-A", plt.Fmt{L: io.Sf("t=%g", out.Times[kt])}, kt)
	out.Splot("")
	out.Plot("x", "pl", "section-B", plt.Fmt{L: "t=0"}, 0)
	out.Plot("x", "pl", "section-B", plt.Fmt{L: io.Sf("t=%g", out.Times[kt])}, kt)
	out.Splot("")
	out.Plot("t", nwlx_TM, "top-middle", plt.Fmt{}, -1)
	out.Csplot.Ylbl = "$n_{\\ell}\\cdot w_{\\ell x}$"

	// show
	if true {
		out.Draw("", "", true, func(i, j, nplots int) {
			if i == 2 && j == 1 {
				plt.Plot([]float64{0, 10}, []float64{10, 9}, "'k--'")
			}
		})
	}
}
Exemple #7
0
func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "a-coarse-elast-d2-q9.sim", ".sim", true)

	// start analysis process
	out.Start(filename, 0, 0)

	// define entities
	out.Define("A B C D E", out.N{-1, -2, -3, -4, -5})                       // top => bottom
	out.Define("a b c d e", out.P{{18, 8}, {8, 8}, {4, 8}, {30, 8}, {0, 0}}) // top => bottom

	// load results
	out.LoadResults(nil)

	// styles
	me := 10
	S := []plt.Fmt{
		plt.Fmt{C: "b", M: "*", Me: me},
		plt.Fmt{C: "g", M: "o", Me: me},
		plt.Fmt{C: "m", M: "x", Me: me},
		plt.Fmt{C: "orange", M: "+", Me: me},
		plt.Fmt{C: "r", M: "^", Me: me},
	}

	// pl
	out.Splot("liquid pressure")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "pl", l, S[i], -1)
	}

	// uy
	out.Splot("displacements")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "uy", l, S[i], -1)
	}

	out.Splot("liquid saturation")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sl", l, S[i], -1)
	}

	out.Splot("stresses")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sy", l, S[i], -1)
	}

	// show
	plt.SetForPng(1, 500, 200)
	out.Draw("/tmp", "up_indentation2d_unsat_"+fnkey+".png", false, nil)
}
Exemple #8
0
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'")
	})
}
Exemple #9
0
func main() {

	// finalise analysis process and catch errors upon exit
	defer out.End()

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

	// define entities
	out.Define("rod", out.Along{{0.05, 0.2, 0.05}, {0.05, 0.6, 0.05}})

	// load results
	out.LoadResults([]float64{0.2, 0.4, 0.6, 0.8, 0.9, 0.98, 1})

	// read comparison results
	rcmp_nod := read_pyfem_rod_data("cmp/pyfem_o2_rod_nod.dat")

	// plot uy along y for selected times
	out.Splot("rod displacements")
	for i, _ := range out.TimeInds {
		out.Plot("y", "uy", "rod", plt.Fmt{}, i)
	}
	for _, d := range rcmp_nod {
		plt.Plot(d.Y, d.Uy, "'k+', ms=5")
	}

	// show
	out.Draw("", "", true, nil)
}
Exemple #10
0
func main() {

	// finalise analysis process and catch errors
	defer out.End()
	var sol ana.PressCylin
	sol.Init(fun.Prms{
		&fun.Prm{N: "a", V: 100},
		&fun.Prm{N: "b", V: 200},
		&fun.Prm{N: "E", V: 210},
		&fun.Prm{N: "ν", V: 0.3},
		&fun.Prm{N: "σy", V: 0.24},
		&fun.Prm{N: "P", V: 0.2},
	})

	// start analysis process
	datadir := "$GOPATH/src/github.com/cpmech/gofem/examples/spo751_pressurised_cylinder/"
	out.Start(datadir+"spo751.sim", 0, 0)

	// define entities
	out.Define("A", out.N{0})
	out.Define("B", out.N{20})
	out.Define("bottom", out.Along{{100, 0}, {101, 0}})

	// load results
	out.LoadResults(nil)

	out.Splot("Pressure at inner and outer face")
	out.Plot("ux", "t", "A", plt.Fmt{C: "b", M: ".", L: "inner"}, -1)
	out.Plot("ux", "t", "B", plt.Fmt{C: "r", M: ".", L: "outer"}, -1)

	//out.Splot("radial stress")
	//X, _, _ := out.GetXYZ("ux", "bottom")
	//SR := make([]float64, len(X))
	//ST := make([]float64, len(X))
	//c := sol.Getc()
	//sol.Sig(c, X, SR, ST)

	//out.Plt(X, ST, "bottom", plt.FmtS{"b.-"}, -1)

	// show
	out.Draw("", "", true, nil)
}
Exemple #11
0
func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "d2-simple-flux", ".sim", true)

	// start analysis process
	out.Extrap = []string{"nwlx", "nwly"}
	out.Start(filename, 0, 0)

	// define entities
	out.Define("top-middle", out.At{5, 3})
	out.Define("section-A", out.N{-1})
	out.Define("section-B", out.Along{{0, 0}, {10, 0}})

	// load results
	out.LoadResults(nil)

	// compute water discharge along section-A
	nwlx_TM := out.GetRes("ex_nwlx", "top-middle", -1)
	Q := out.Integrate("ex_nwlx", "section-A", "y", -1)
	io.PfYel("Q = %g m³/s [answer: 0.0003]\n", Q)

	// plot
	kt := len(out.Times) - 1
	out.Splot("")
	out.Plot("pl", "y", "section-A", plt.Fmt{L: "t=0"}, 0)
	out.Plot("pl", "y", "section-A", plt.Fmt{L: io.Sf("t=%g", out.Times[kt])}, kt)
	out.Splot("")
	out.Plot("x", "pl", "section-B", plt.Fmt{L: "t=0"}, 0)
	out.Plot("x", "pl", "section-B", plt.Fmt{L: io.Sf("t=%g", out.Times[kt])}, kt)
	out.Splot("")
	out.Plot("t", nwlx_TM, "top-middle", plt.Fmt{}, -1)
	out.Csplot.Ylbl = "$n_{\\ell}\\cdot w_{\\ell x}$"

	// save
	plt.SetForPng(1.5, 400, 200)
	out.Draw("/tmp", "seep_simple_flux_"+fnkey+".png", false, func(i, j, nplots int) {
		if i == 2 && j == 1 {
			plt.Plot([]float64{0, 10}, []float64{10, 9}, "'k--'")
		}
	})
}
Exemple #12
0
func main() {

	// finalise analysis process and catch errors
	defer out.End()

	// input data
	simfn := "a-coarse-elast-d2-q9"
	flag.Parse()
	if len(flag.Args()) > 0 {
		simfn = flag.Arg(0)
	}
	if io.FnExt(simfn) == "" {
		simfn += ".sim"
	}

	// start analysis process
	out.Start(simfn, 0, 0)

	// define entities
	out.Define("a", out.P{{18, 8}})

	// load results
	out.LoadResults(nil)

	nf_a := out.GetRes("nf", "a", -1)
	pl_a := out.GetRes("pl", "a", -1)
	pc_a := make([]float64, len(pl_a))
	for i, _ := range pl_a {
		pc_a[i] = -pl_a[i]
	}

	out.Splot("LRM")
	_, d, _ := io.ReadTable("lrm.dat")
	plt.Plot(d["pc"], d["sl"], "'c-',lw=2")

	out.Plot(pc_a, "sl", "a", plt.Fmt{M: "o"}, -1)
	out.Csplot.Xlbl = "$p_c$"

	out.Splot("porosity")
	out.Plot("t", nf_a, "a", plt.Fmt{M: "+"}, -1)
	out.Csplot.Ylbl = "$n_f$"

	// show
	out.Draw("", "", true, nil)
}
Exemple #13
0
func main() {

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

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

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

	// old results
	b, err := io.ReadFile("cmp/sg1121gofemold.json")
	if err != nil {
		io.PfRed("cannot read comparison file\n")
		return
	}
	var gofemold struct {
		Time, Uy30 []float64
	}
	err = json.Unmarshal(b, &gofemold)
	if err != nil {
		io.PfRed("cannot unmarshal comparison file\n")
		return
	}

	// mechsys results
	_, res, err := io.ReadTable("cmp/sg1121mechsysN30.cmp")
	if err != nil {
		io.PfRed("cannot read mechsys comparison file\n")
		return
	}

	// save
	plt.SetForPng(0.8, 400, 200)
	out.Draw("/tmp", fnkey+".png", false, func(i, j, n int) {
		plt.Plot(gofemold.Time, gofemold.Uy30, "'r-', lw=2, label='gofemOld'")
		plt.Plot(res["Time"], res["uy"], "'b-', label='mechsys'")
	})
}
Exemple #14
0
func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "a-coarse-elast-d2-q9", ".sim", true)

	// start analysis process
	out.Start(filename, 0, 0)

	// define entities
	out.Define("a", out.P{{18, 8}})

	// load results
	out.LoadResults(nil)

	nf_a := out.GetRes("nf", "a", -1)
	pl_a := out.GetRes("pl", "a", -1)
	pc_a := make([]float64, len(pl_a))
	for i, _ := range pl_a {
		pc_a[i] = -pl_a[i]
	}

	out.Splot("LRM")
	_, d, _ := io.ReadTable("lrm.dat")
	plt.Plot(d["pc"], d["sl"], "'c-',lw=2")

	out.Plot(pc_a, "sl", "a", plt.Fmt{M: "o"}, -1)
	out.Csplot.Xlbl = "$p_c$"

	out.Splot("porosity")
	out.Plot("t", nf_a, "a", plt.Fmt{M: "+"}, -1)
	out.Csplot.Ylbl = "$n_f$"

	// show
	plt.SetForPng(1.2, 500, 200)
	out.Draw("/tmp", "up_indentation2d_unsat_lrm_"+fnkey+".png", false, nil)
}
Exemple #15
0
func main() {

	// filename
	filename, fnkey := io.ArgToFilename(0, "onepulse-qua9co.sim", ".sim", true)

	// start analysis process
	out.Start(filename, 0, 0)

	// define entities
	out.Define("A B C D E", out.N{-5, -4, -3, -2, -1})
	out.Define("a b c d e", out.P{{15, 8}, {13, 8}, {8, 8}, {4, 8}, {0, 0}})
	out.Define("left-side", out.Along{{0, 0}, {0, 3}})

	// load results
	out.LoadResults(nil)

	// styles
	me := 10
	S := []plt.Fmt{
		plt.Fmt{C: "b", M: "*", Me: me},
		plt.Fmt{C: "g", M: "o", Me: me},
		plt.Fmt{C: "m", M: "x", Me: me},
		plt.Fmt{C: "orange", M: "+", Me: me},
		plt.Fmt{C: "r", M: "^", Me: me},
	}

	// pl
	out.Splot("liquid pressure")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "pl", l, S[i], -1)
	}

	// uy
	out.Splot("displacements")
	for i, l := range []string{"A", "B", "C", "D", "E"} {
		out.Plot("t", "uy", l, S[i], -1)
	}

	// sl
	out.Splot("liquid saturation")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sl", l, S[i], -1)
	}

	// sy
	out.Splot("stresses")
	for i, l := range []string{"a", "b", "c", "d", "e"} {
		out.Plot("t", "sy", l, S[i], -1)
	}

	// pl
	out.Splot("pressure along column")
	I, _ := utl.GetITout(out.Times, []float64{0, 1000, 2000, 3000, 4000}, 0.1)
	for _, i := range I {
		t := out.Times[i]
		out.Plot("pl", "y", "left-side", plt.Fmt{L: io.Sf("t=%g", t)}, i)
	}

	// empty
	out.Splot("")

	// save
	plt.SetForPng(1.2, 800, 200)
	out.Draw("/tmp", "up_3mcolumn_dessication_"+fnkey+".png", false, nil)
}