func (o *Plotter) Plot_Dgam_f(x, y []float64, res []*State, sts [][]float64, last bool) { if o.m == nil { o.set_empty() return } nr := len(res) k := nr - 1 ys := o.m.YieldFuncs(res[0]) fc0 := ys[0] xmi, xma, ymi, yma := res[0].Dgam, res[0].Dgam, fc0, fc0 for i := 0; i < nr; i++ { x[i] = res[i].Dgam ys = o.m.YieldFuncs(res[i]) y[i] = ys[0] xmi = min(xmi, x[i]) xma = max(xma, x[i]) ymi = min(ymi, y[i]) yma = max(yma, y[i]) } //o.DrawRamp(xmi, xma, ymi, yma) plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) if last { plt.Gll("$\\Delta\\gamma$", "$f$", "") if lims, ok := o.Lims["Dgam,f"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_i_alp(x, y []float64, res []*State, sts [][]float64, last bool) { nr := len(res) nα := len(res[0].Alp) if nα == 0 { o.set_empty() return } yy := la.MatAlloc(nα, nr) for i := 0; i < nr; i++ { x[i] = float64(i) for j := 0; j < nα; j++ { yy[j][i] = res[i].Alp[j] } } for j := 0; j < nα; j++ { lbl := io.Sf("$\\alpha_%d$ "+o.Lbl, j) plt.Plot(x, yy[j], io.Sf("'r-', ls='-', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, lbl)) } if last { plt.Gll("$i$", "$\\alpha_k$", "leg_out=1, leg_ncol=4, leg_hlen=2") if lims, ok := o.Lims["i,alp"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_i_f(x, y []float64, res []*State, sts [][]float64, last bool) { if o.m == nil { o.set_empty() return } nr := len(res) var y2 []float64 if o.nsurf > 1 { y2 = make([]float64, nr) } for i := 0; i < nr; i++ { ys := o.m.YieldFuncs(res[i]) y[i] = ys[0] if o.nsurf > 1 { y2[i] = ys[1] } x[i] = float64(i) } lbl := "f " + o.Lbl plt.Plot(x, y, io.Sf("'r.', ls='-', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, lbl)) if o.nsurf > 1 { lbl = "F " + o.Lbl plt.Plot(x, y2, io.Sf("'b+', ls=':', lw=2, clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, lbl)) } if last { plt.Gll("$i$", "$f,\\;F$", "leg_out=1, leg_ncol=4, leg_hlen=2") if lims, ok := o.Lims["i,f"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_ed_q(x, y []float64, res []*State, sts [][]float64, last bool) { nr := len(res) if len(sts) != nr { return } k := nr - 1 for i := 0; i < nr; i++ { x[i] = o.Ed[i] * 100.0 if o.QdivP { y[i] = o.Q[i] / o.P[i] } else { y[i] = o.Q[i] } if o.Multq { y[i] *= fun.Sign(o.W[i]) } } plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) if last { ylbl := "$q$" if o.QdivP { ylbl = "$q/p$" } plt.Gll("$\\varepsilon_d\\;[\\%]$", ylbl, "leg_out=1, leg_ncol=4, leg_hlen=1.5") if lims, ok := o.Lims["ed,q"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_ed_ev(x, y []float64, res []*State, sts [][]float64, last bool) { nr := len(sts) k := nr - 1 for i := 0; i < nr; i++ { x[i], y[i] = o.Ed[i]*100.0, o.Ev[i]*100.0 } plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) if last { plt.Gll("$\\varepsilon_d\\;[\\%]$", "$\\varepsilon_v\\;[\\%]$", "leg_out=1, leg_ncol=4, leg_hlen=1.5") if lims, ok := o.Lims["ed,ev"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_s3_s1(x, y []float64, res []*State, sts [][]float64, last bool) { // stress path nr := len(res) k := nr - 1 x2 := make([]float64, nr) var xmi, xma, ymi, yma float64 for i := 0; i < nr; i++ { σ1, σ2, σ3, err := tsr.M_PrincValsNum(res[i].Sig) if err != nil { chk.Panic("computation of eigenvalues failed", err) } x[i], y[i] = -tsr.SQ2*σ3, -σ1 x2[i] = -tsr.SQ2 * σ2 if i == 0 { xmi, xma = x[i], x[i] ymi, yma = y[i], y[i] } else { xmi = min(min(xmi, x[i]), x2[i]) xma = max(max(xma, x[i]), x2[i]) ymi = min(ymi, y[i]) yma = max(yma, y[i]) } } plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'$\\sigma_3$ %s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.Plot(x2, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'$\\sigma_2$ %s'", o.LsAlt, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) // yield surface if o.WithYs && o.m != nil { if o.UsePmin { xmi = min(xmi, o.Pmin*tsr.SQ2) ymi = min(ymi, o.Pmin) } if o.UsePmax { xma = max(xma, o.Pmax*tsr.SQ2) yma = max(yma, o.Pmax) } xmi, xma, ymi, yma = o.fix_range(0, xmi, xma, ymi, yma) if o.S3s1Lims != nil { xmi, xma, ymi, yma = o.S3s1Lims[0], o.S3s1Lims[1], o.S3s1Lims[2], o.S3s1Lims[3] } //io.Pforan("xmi,xma ymi,yma = %v,%v %v,%v\n", xmi,xma, ymi,yma) dx := (xma - xmi) / float64(o.NptsSig-1) dy := (yma - ymi) / float64(o.NptsSig-1) xx := la.MatAlloc(o.NptsSig, o.NptsSig) yy := la.MatAlloc(o.NptsSig, o.NptsSig) zz := la.MatAlloc(o.NptsSig, o.NptsSig) v := NewState(len(res[0].Sig), len(res[0].Alp), false, len(res[0].EpsE) > 0) for k := 0; k < nr; k++ { copy(v.Alp, res[k].Alp) v.Dgam = res[k].Dgam for i := 0; i < o.NptsSig; i++ { for j := 0; j < o.NptsSig; j++ { xx[i][j] = xmi + float64(i)*dx yy[i][j] = ymi + float64(j)*dy v.Sig[0], v.Sig[1], v.Sig[2] = -yy[i][j], -xx[i][j]/tsr.SQ2, -xx[i][j]/tsr.SQ2 ys := o.m.YieldFuncs(v) zz[i][j] = ys[0] } } plt.ContourSimple(xx, yy, zz, io.Sf("colors=['%s'], levels=[0], linestyles=['%s'], linewidths=[%g], clip_on=0", o.YsClr0, o.YsLs0, o.YsLw0)+o.ArgsYs) } } // predictor-corrector if len(o.PreCor) > 1 { var σ3, σ1, σ3new, σ1new float64 for i := 1; i < len(o.PreCor); i++ { σ1, _, σ3, _ = tsr.M_PrincValsNum(o.PreCor[i-1]) σ1new, _, σ3new, _ = tsr.M_PrincValsNum(o.PreCor[i]) if math.Abs(σ3new-σ3) > 1e-7 || math.Abs(σ1new-σ1) > 1e-7 { plt.Arrow(-σ3*tsr.SQ2, -σ1, -σ3new*tsr.SQ2, -σ1new, io.Sf("sc=%d, fc='%s', ec='%s'", o.ArrWid, o.ClrPC, o.ClrPC)) } } } // settings if last { plt.Equal() plt.Gll("$-\\sqrt{2}\\sigma_3$", "$-\\sigma_1$", "leg=1, leg_out=1, leg_ncol=4, leg_hlen=2") if lims, ok := o.Lims["s3,s1"]; ok { plt.AxisLims(lims) } if lims, ok := o.Lims["s3,s1,ys"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_oct(x, y []float64, res []*State, sts [][]float64, last bool) { // stress path nr := len(res) k := nr - 1 var σa, σb, xmi, xma, ymi, yma float64 for i := 0; i < nr; i++ { σa, σb, _ = tsr.PQW2O(o.P[i], o.Q[i], o.W[i]) x[i], y[i] = σa, σb o.maxR = max(o.maxR, math.Sqrt(σa*σa+σb*σb)) if i == 0 { xmi, xma = x[i], x[i] ymi, yma = y[i], y[i] } else { xmi = min(xmi, x[i]) xma = max(xma, x[i]) ymi = min(ymi, y[i]) yma = max(yma, y[i]) } } plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) // fix range and max radius xmi, xma, ymi, yma = o.fix_range(0, xmi, xma, ymi, yma) rr := math.Sqrt((xma-xmi)*(xma-xmi) + (yma-ymi)*(yma-ymi)) if o.maxR < rr { o.maxR = rr } if o.maxR < 1e-10 { o.maxR = 1 } if yma > -xmi { xmi = -yma } if o.OctLims != nil { xmi, xma, ymi, yma = o.OctLims[0], o.OctLims[1], o.OctLims[2], o.OctLims[3] } //xmi, xma, ymi, yma = -20000, 20000, -20000, 20000 // yield surface var σcmax float64 if o.WithYs && o.m != nil { //io.Pforan("xmi,xma ymi,yma = %v,%v %v,%v\n", xmi,xma, ymi,yma) dx := (xma - xmi) / float64(o.NptsOct-1) dy := (yma - ymi) / float64(o.NptsOct-1) xx := la.MatAlloc(o.NptsOct, o.NptsOct) yy := la.MatAlloc(o.NptsOct, o.NptsOct) zz := la.MatAlloc(o.NptsOct, o.NptsOct) var λ0, λ1, λ2, σc float64 v := NewState(len(res[0].Sig), len(res[0].Alp), false, len(res[0].EpsE) > 0) for k := 0; k < nr; k++ { copy(v.Alp, res[k].Alp) v.Dgam = res[k].Dgam σc = tsr.M_p(res[k].Sig) * tsr.SQ3 //σc = 30000 σcmax = max(σcmax, σc) for i := 0; i < o.NptsOct; i++ { for j := 0; j < o.NptsOct; j++ { xx[i][j] = xmi + float64(i)*dx yy[i][j] = ymi + float64(j)*dy λ0, λ1, λ2 = tsr.O2L(xx[i][j], yy[i][j], σc) v.Sig[0], v.Sig[1], v.Sig[2] = λ0, λ1, λ2 ys := o.m.YieldFuncs(v) zz[i][j] = ys[0] } } plt.ContourSimple(xx, yy, zz, io.Sf("colors=['%s'], levels=[0], linestyles=['%s'], linewidths=[%g], clip_on=0", o.YsClr0, o.YsLs0, o.YsLw0)+o.ArgsYs) } } // predictor-corrector if len(o.PreCor) > 1 { var σa, σb, σanew, σbnew float64 for i := 1; i < len(o.PreCor); i++ { σa, σb, _ = tsr.M_oct(o.PreCor[i-1]) σanew, σbnew, _ = tsr.M_oct(o.PreCor[i]) if math.Abs(σanew-σa) > 1e-7 || math.Abs(σbnew-σb) > 1e-7 { //plt.Plot([]float64{σa,σanew}, []float64{σb,σbnew}, "'k+', ms=3, color='k'") plt.Arrow(σa, σb, σanew, σbnew, io.Sf("sc=%d, fc='%s', ec='%s'", o.ArrWid, o.ClrPC, o.ClrPC)) } o.maxR = max(o.maxR, math.Sqrt(σa*σa+σb*σb)) o.maxR = max(o.maxR, math.Sqrt(σanew*σanew+σbnew*σbnew)) } } // rosette and settings if last { tsr.PlotRefOct(o.Phi, σcmax, true) tsr.PlotRosette(o.maxR, false, true, true, 6) if o.OctAxOff { plt.AxisOff() } plt.Gll("$\\sigma_a$", "$\\sigma_b$", "") if lims, ok := o.Lims["oct"]; ok { plt.AxisLims(lims) } if lims, ok := o.Lims["oct,ys"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_p_q(x, y []float64, res []*State, sts [][]float64, last bool) { // stress path nr := len(res) k := nr - 1 var xmi, xma, ymi, yma float64 for i := 0; i < nr; i++ { x[i], y[i] = o.P[i], o.Q[i] if o.Multq { mult := fun.Sign(o.W[i]) y[i] *= mult } if o.UseOct { x[i] *= tsr.SQ3 y[i] *= tsr.SQ2by3 } if i == 0 { xmi, xma = x[i], x[i] ymi, yma = y[i], y[i] } else { xmi = min(xmi, x[i]) xma = max(xma, x[i]) ymi = min(ymi, y[i]) yma = max(yma, y[i]) } if o.SMPon { x[i], y[i], _ = tsr.M_pq_smp(res[i].Sig, o.SMPa, o.SMPb, o.SMPβ, o.SMPϵ) } } plt.Plot(x, y, io.Sf("'r.', ls='%s', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Ls, o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) // yield surface if o.WithYs && o.m != nil { mx, my := 1.0, 1.0 if o.UseOct { mx, my = tsr.SQ3, tsr.SQ2by3 } if o.UsePmin { xmi = min(xmi, o.Pmin*mx) } if o.UsePmax { xma = max(xma, o.Pmax*mx) yma = max(yma, o.Pmax*my) } xmi, xma, ymi, yma = o.fix_range(xmi, xmi, xma, ymi, yma) if o.PqLims != nil { xmi, xma, ymi, yma = o.PqLims[0], o.PqLims[1], o.PqLims[2], o.PqLims[3] } //io.Pforan("xmi,xma ymi,yma = %v,%v %v,%v\n", xmi,xma, ymi,yma) dx := (xma - xmi) / float64(o.NptsPq-1) dy := (yma - ymi) / float64(o.NptsPq-1) xx := la.MatAlloc(o.NptsPq, o.NptsPq) yy := la.MatAlloc(o.NptsPq, o.NptsPq) za := la.MatAlloc(o.NptsPq, o.NptsPq) zb := la.MatAlloc(o.NptsPq, o.NptsPq) var p, q, σa, σb, σc, λ0, λ1, λ2 float64 v := NewState(len(res[0].Sig), len(res[0].Alp), false, len(res[0].EpsE) > 0) for k := 0; k < nr; k++ { copy(v.Alp, res[k].Alp) v.Dgam = res[k].Dgam for i := 0; i < o.NptsPq; i++ { for j := 0; j < o.NptsPq; j++ { xx[i][j] = xmi + float64(i)*dx yy[i][j] = ymi + float64(j)*dy p, q = xx[i][j], yy[i][j] if o.UseOct { p /= tsr.SQ3 q /= tsr.SQ2by3 } σa, σb, σc = tsr.PQW2O(p, q, o.W[k]) λ0, λ1, λ2 = tsr.O2L(σa, σb, σc) v.Sig[0], v.Sig[1], v.Sig[2] = λ0, λ1, λ2 ys := o.m.YieldFuncs(v) za[i][j] = ys[0] if o.nsurf > 1 { zb[i][j] = ys[1] } if o.SMPon { xx[i][j], yy[i][j], _ = tsr.M_pq_smp(v.Sig, o.SMPa, o.SMPb, o.SMPβ, o.SMPϵ) } } } plt.ContourSimple(xx, yy, za, io.Sf("colors=['%s'], levels=[0], linestyles=['%s'], linewidths=[%g], clip_on=0", o.YsClr0, o.YsLs0, o.YsLw0)+o.ArgsYs) if o.nsurf > 1 { plt.ContourSimple(xx, yy, zb, io.Sf("colors=['%s'], levels=[0], linestyles=['%s'], linewidths=[%g], clip_on=0", o.YsClr1, o.YsLs1, o.YsLw1)+o.ArgsYs) } } } // predictor-corrector if len(o.PreCor) > 1 { var p, q, pnew, qnew float64 for i := 1; i < len(o.PreCor); i++ { p = tsr.M_p(o.PreCor[i-1]) q = tsr.M_q(o.PreCor[i-1]) pnew = tsr.M_p(o.PreCor[i]) qnew = tsr.M_q(o.PreCor[i]) if o.UseOct { p *= tsr.SQ3 pnew *= tsr.SQ3 q *= tsr.SQ2by3 qnew *= tsr.SQ2by3 } if o.SMPon { p, q, _ = tsr.M_pq_smp(o.PreCor[i-1], o.SMPa, o.SMPb, o.SMPβ, o.SMPϵ) pnew, qnew, _ = tsr.M_pq_smp(o.PreCor[i], o.SMPa, o.SMPb, o.SMPβ, o.SMPϵ) } if math.Abs(pnew-p) > 1e-10 || math.Abs(qnew-q) > 1e-10 { plt.Arrow(p, q, pnew, qnew, io.Sf("sc=%d, fc='%s', ec='%s'", o.ArrWid, o.ClrPC, o.ClrPC)) } } } // settings if last { plt.Equal() xl, yl := "$p_{cam}$", "$q_{cam}$" if o.UseOct { xl, yl = "$p_{oct}$", "$q_{oct}$" } if o.SMPon { xl, yl = "$p_{smp}$", "$q_{smp}$" } if o.AxLblX != "" { xl = o.AxLblX } if o.AxLblY != "" { yl = o.AxLblY } plt.Gll(xl, yl, "leg_out=1, leg_ncol=4, leg_hlen=1.5") if lims, ok := o.Lims["p,q"]; ok { plt.AxisLims(lims) } if lims, ok := o.Lims["p,q,ys"]; ok { plt.AxisLims(lims) } } }
func (o *Plotter) Plot_p_ev(x, y []float64, res []*State, sts [][]float64, last bool) { nr := len(res) if len(sts) != nr { return } k := nr - 1 var x0, x1 []float64 if !o.NoAlp { x0, x1 = make([]float64, nr), make([]float64, nr) } withα := false if o.LogP { xmin := o.calc_x(o.P[0]) xmax := xmin for i := 0; i < nr; i++ { x[i], y[i] = o.calc_x(o.P[i]), o.Ev[i]*100.0 if !o.NoAlp && len(res[i].Alp) > 0 { withα = true x0[i] = o.calc_x(res[i].Alp[0]) if o.nsurf > 1 { x1[i] = o.calc_x(res[i].Alp[1]) } } xmin = min(xmin, x[i]) xmax = max(xmax, x[i]) } } else { xmin := o.P[0] xmax := xmin for i := 0; i < nr; i++ { x[i], y[i] = o.P[i], o.Ev[i]*100.0 if !o.NoAlp && len(res[i].Alp) > 0 { withα = true x0[i] = res[i].Alp[0] if o.nsurf > 1 { x1[i] = res[i].Alp[1] } } xmin = min(xmin, x[i]) xmax = max(xmax, x[i]) } } if withα { plt.Plot(x0, y, io.Sf("'r-', ls='--', lw=3, clip_on=0, color='grey', label=r'%s'", o.Lbl+" $\\alpha_0$")) if o.nsurf > 1 { plt.Plot(x1, y, io.Sf("'r-', ls=':', lw=3, clip_on=0, color='grey', label=r'%s'", o.Lbl+" $\\alpha_1$")) } } plt.Plot(x, y, io.Sf("'r.', ls='-', clip_on=0, color='%s', marker='%s', label=r'%s'", o.Clr, o.Mrk, o.Lbl)) plt.PlotOne(x[0], y[0], io.Sf("'bo', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.SpMrk, o.SpMs)) plt.PlotOne(x[k], y[k], io.Sf("'bs', clip_on=0, color='%s', marker='%s', ms=%d", o.SpClr, o.EpMrk, o.EpMs)) if last { xlbl := "$p$" if o.LogP { xlbl = "$\\log{[1+(p+p_t)/p_r]}$" } plt.Gll(xlbl, "$\\varepsilon_v\\;[\\%]$", "leg_out=1, leg_ncol=4, leg_hlen=2") if lims, ok := o.Lims["p,ev"]; ok { plt.AxisLims(lims) } } }