Beispiel #1
0
// L_update computes principal stresses for given principal strains
func (o *HyperElast1) L_update(σ, ε []float64) (p, q float64) {
	eno, εv, εd := tsr.M_devε(o.e, ε) // using principal values since len(ε)=3
	p, q = o.Calc_pq(εv, εd)
	if eno > o.EnoMin {
		for i := 0; i < 3; i++ {
			σ[i] = -p*tsr.Im[i] + tsr.SQ2by3*q*o.e[i]/eno
		}
		return
	}
	for i := 0; i < 3; i++ {
		σ[i] = -p * tsr.Im[i]
	}
	return
}
Beispiel #2
0
// Update updates stresses for given strains
func (o *HyperElast1) Update(s *State, ε, dummy []float64, eid, ipid int, time float64) (err error) {
	eno, εv, εd := tsr.M_devε(o.e, ε)
	p, q := o.Calc_pq(εv, εd)
	if eno > o.EnoMin {
		for i := 0; i < o.Nsig; i++ {
			s.Sig[i] = -p*tsr.Im[i] + tsr.SQ2by3*q*o.e[i]/eno
		}
		return
	}
	for i := 0; i < o.Nsig; i++ {
		s.Sig[i] = -p * tsr.Im[i]
	}
	return
}
Beispiel #3
0
// L_CalcD computes De in principal components for given principal elastic strains
//  D -- [ncp][ncp] elastic modulus
//  ε -- [ncp] elastic strains
//
//  Note: this method works also for non-principal components
//
func (o *HyperElast1) L_CalcD(D [][]float64, ε []float64) {

	// number of components
	ncp := len(ε)
	if ncp == 0 {
		ncp = o.Nsig
	}

	// elastic modulus
	I, Psd := tsr.Im, tsr.Psd
	if o.le {
		for i := 0; i < ncp; i++ {
			for j := 0; j < ncp; j++ {
				D[i][j] = o.K0*I[i]*I[j] + 2.0*o.G0*Psd[i][j]
			}
		}
		return
	}

	// invariants of strain and normalised deviatoric direction
	eno, εv, εd := tsr.M_devε(o.e, ε)
	if eno > o.EnoMin {
		for i := 0; i < ncp; i++ {
			o.e[i] /= eno
		}
	} else {
		for i := 0; i < ncp; i++ {
			o.e[i] = 0
		}
	}

	// Dvv = ∂²ψ/(∂εve ∂εve)
	// DvdS = (∂²ψ/(∂εve ∂εde)) * sqrt(2/3)
	// Ddd2 = (∂²ψ/(∂εde ∂εde)) * 2 / 3
	pv := o.pa * math.Exp(-o.a*εv)
	Dvv := o.a * (1.0 + 1.5*o.a*o.κb*εd*εd) * pv
	DvdS := -3.0 * o.a * o.κb * εd * pv * tsr.SQ2by3
	Ddd2 := 2.0 * (o.G0 + o.κb*pv)
	for i := 0; i < ncp; i++ {
		for j := 0; j < ncp; j++ {
			D[i][j] = Dvv*I[i]*I[j] + Ddd2*Psd[i][j] + DvdS*(I[i]*o.e[j]+o.e[i]*I[j])
		}
	}
}
Beispiel #4
0
// Plot runs the plot generation (basic set)
func (o *Plotter) Plot(keys []string, res []*State, sts [][]float64, first, last bool) {

	// auxiliary variables
	nr := imax(len(res), len(sts))
	if nr < 1 {
		return
	}
	x := make([]float64, nr)
	y := make([]float64, nr)
	o.P = make([]float64, nr)
	o.Q = make([]float64, nr)
	o.W = make([]float64, nr)
	o.Ev = make([]float64, nr)
	o.Ed = make([]float64, nr)

	// compute invariants
	for i := 0; i < len(res); i++ {
		if len(res[i].Sig) < 4 {
			chk.Panic("number of stress components is incorrect: %d", len(res[i].Sig))
		}
		o.P[i], o.Q[i], o.W[i] = tsr.M_pqw(res[i].Sig)
	}
	nsig := len(res[0].Sig)
	devε := make([]float64, nsig)
	for i := 0; i < len(sts); i++ {
		if len(sts[i]) < 4 {
			chk.Panic("number of strain components is incorrect: %d", len(sts[i]))
		}
		_, o.Ev[i], o.Ed[i] = tsr.M_devε(devε, sts[i])
	}

	// clear previous figure
	if first {
		plt.Clf()
		plt.SplotGap(0.35, 0.35)
		if o.Hspace > 0 {
			plt.SetHspace(o.Hspace)
		}
		if o.Vspace > 0 {
			plt.SetVspace(o.Vspace)
		}
	}

	// number of points for contour
	if o.NptsPq < 2 {
		o.NptsPq = 61
	}
	if o.NptsOct < 2 {
		o.NptsOct = 41
	}
	if o.NptsSig < 2 {
		o.NptsSig = 41
	}

	// subplot variables
	o.Pidx = 1
	o.Ncol, o.Nrow = utl.BestSquare(len(keys))
	if len(keys) == 2 {
		o.Ncol, o.Nrow = 1, 2
	}
	if len(keys) == 3 {
		o.Ncol, o.Nrow = 1, 3
	}

	// do plot
	for _, key := range keys {
		o.Subplot()
		switch key {
		case "ed,q":
			o.QdivP = false
			o.Plot_ed_q(x, y, res, sts, last)
		case "ed,q/p":
			o.QdivP = true
			o.Plot_ed_q(x, y, res, sts, last)
		case "p,q":
			o.WithYs = false
			o.Plot_p_q(x, y, res, sts, last)
		case "p,q,ys":
			o.WithYs = true
			o.Plot_p_q(x, y, res, sts, last)
		case "ed,ev":
			o.Plot_ed_ev(x, y, res, sts, last)
		case "p,ev":
			o.LogP = false
			o.Plot_p_ev(x, y, res, sts, last)
		case "log(p),ev":
			o.LogP = true
			o.Plot_p_ev(x, y, res, sts, last)
		case "i,f":
			o.Plot_i_f(x, y, res, sts, last)
		case "i,alp":
			o.Plot_i_alp(x, y, res, sts, last)
		case "Dgam,f":
			o.Plot_Dgam_f(x, y, res, sts, last)
		case "oct":
			o.WithYs = false
			o.Plot_oct(x, y, res, sts, last)
		case "oct,ys":
			o.WithYs = true
			o.Plot_oct(x, y, res, sts, last)
		case "s3,s1":
			o.WithYs = false
			o.Plot_s3_s1(x, y, res, sts, last)
		case "s3,s1,ys":
			o.WithYs = true
			o.Plot_s3_s1(x, y, res, sts, last)
		case "empty":
			continue
		default:
			chk.Panic("cannot handle key=%q", key)
		}
		if o.Split && last {
			o.Save("_", key)
		}
	}

	// save figure
	if !o.Split && last {
		o.Save("", "")
	}
}