integrals_generate_code¶
Class summary¶
SympyVarsFor1DSpectralDerivation ([...]) |
Container for sympy vars, z, zt, zb, at, etc piecewise linear Spectral Galerkin integrations. |
Function summary¶
EDload_coslinear_implementations () |
Code generation for Integration of D[cos(omega*tau+phase)*load(tau), tau] * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear. |
EDload_linear_implementations () |
Code generation for Integration of D[load(tau), tau] * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear. |
Eload_coslinear_implementations () |
Code generation for Integration of cos(omega*tau+phase)*load(tau) * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear. |
Eload_linear_implementations () |
Code generation for Integration of load(tau) * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear. |
dim1_ab_linear_between () |
Code generation for Integrations of a(z) * b(z) between [z1, z2] where a(z) is a piecewise linear functions of z. |
dim1sin_DD_abDDf_linear_implementations () |
Code generation for Integration of sin(mi * z) * D[a(z) * b(z) D[sin(mj * z),z,2],z,2] between ztop and zbot where a(z) and b(z) is piecewise linear functions of z. |
dim1sin_D_aDb_linear_implementations () |
Code generation for Integrations of sin(mi * z) * D[a(z) * D[b(z), z], z] between ztop and zbot where a(z) is a piecewisepiecewise linear function of z, and b(z) is a linear function of z. |
dim1sin_D_aDf_linear_implementations () |
Code generation for Integration of sin(mi * z) * D[a(z) * D[sin(mj * z),z],z] between ztop and zbot where a(z) is piecewise linear functions of z. |
dim1sin_a_linear_between () |
Code generation for Integrations of sin(mi * z) * a(z) between [z1, z2] where a(z) is a piecewise linear functions of z. |
dim1sin_ab_linear_implementations () |
Code generation for Integration of sin(mi * z) * a(z) * b(z) between ztop and zbot where a(z) and b(z) are piecewise linear functions of z. |
dim1sin_abc_linear_implementations () |
Code generation for Integrations of sin(mi * z) * a(z) * b(z) * c(z) between ztop and zbot where a(z), b(z), c(z) are piecewise linear functions of z. |
dim1sin_abf_linear_implementations () |
Code generation for Integration of sin(mi * z) * a(z) * a(z) * sin(mj * z) between ztop and zbot where a(z) is piecewise linear. |
dim1sin_af_linear_implementations () |
Code generation for Integration of sin(mi * z) * a(z) * sin(mj * z) between ztop and zbot where a(z) is piecewise linear. |
tw (text[, indents, width, break_long_words]) |
Rough text wrapper for long sympy expressions |
Module listing¶
Use sympy to generate code for generating spectral method matrix subroutines
-
geotecha.speccon.integrals_generate_code.
EDload_coslinear_implementations
()[source]¶ Code generation for Integration of D[cos(omega*tau+phase)*load(tau), tau] * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear.
Performs integrations involving a piecewise linear load. A 2d array of dimensions A[len(tvals), len(eigs)] is produced where the ‘i’th row of A contains the diagonal elements of the spectral ‘E’ matrix calculated for the time value tvals[i]. i.e. rows of this matrix will be assembled into the diagonal matrix ‘E’ elsewhere.
Paste the resulting code (at least the loops) into EDload_coslinear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.EDload_coslinear
- Resulting function.
geotecha.speccon.integrals.pEDload_coslinear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.edload_coslinear
- Resulting fortran function.
EDload_linear_implementations
- Similar function with no cosine term.
Eload_coslinear_implementations
- Similar function but the time dependent loading function is not differentiated w.r.t. time.
Notes
Assuming the load are formulated as the product of separate time and depth dependant functions:
\[\sigma\left({Z,t}\right)=\sigma\left({Z}\right)\sigma\left({t}\right)\]the solution to the consolidation equation using the spectral method has the form:
\[u\left(Z,t\right)=\mathbf{\Phi v E}\left(\mathbf{\Gamma v}\right)^{-1}\mathbf{\theta}\]The matrix \(E\) is a time dependent diagonal matrix due to time dependant loadings. The version of \(E\) calculated here in EDload_coslinear is from loading terms in the governing equation that are NOT differentiated wrt \(t\). The diagonal elements of \(E\) are given by:
\[\mathbf{E}_{i,i}=\int_{0}^t{\frac{d{{\cos\left(\omega\tau+\textrm{phase}\right)}\sigma\left(\tau\right)}}{d\tau}{\exp\left({(dT\left(t-\tau\right)\lambda_i}\right)}\,d\tau}\]where
\(\lambda_i\) is the ith eigenvalue of the problem, \(dT\) is a time factor for numerical convienience, \(\sigma\left(\tau\right)\) is the time dependant portion of the loading function.When the time dependant loading term \(\sigma\left(\tau\right)\) is piecewise in time. The contribution of each load segment is found by:
\[\mathbf{E}_{i,i}=\int_{t_s}^{t_f}{\frac{d{{\cos\left(\omega\tau+\textrm{phase}\right)}\sigma\left(\tau\right)}}{d\tau}\exp\left({dT\left(t-\tau\right)*\lambda_i}\right)\,d\tau}\]where
\[t_s = \min\left(t,t_{increment\:start}\right)\]\[t_f = \min\left(t,t_{increment\:end}\right)\](note that this function,`EDload_coslinear`, rather than use \(t_s\) and \(t_f\), explicitly finds increments that the current time falls in, falls after, and falls before and treates each case on it’s own.)
Each \(t\) value of interest requires a separate diagonal matrix \(E\). To use space more efficiently and to facilitate numpy broadcasting when using the results of the function, the diagonal elements of \(E\) for each time value t value are stored in the rows of array \(A\) returned by EDload_coslinear. Thus:
\[\begin{split}\mathbf{A}=\left(\begin{matrix}E_{0,0}(t_0)&E_{1,1}(t_0)& \cdots & E_{neig-1,neig-1}(t_0)\\ E_{0,0}(t_1)&E_{1,1}(t_1)& \cdots & E_{neig-1,neig-1}(t_1)\\ \vdots&\vdots&\ddots&\vdots \\ E_{0,0}(t_m)&E_{1,1}(t_m)& \cdots & E_{neig-1,neig-1}(t_m)\end{matrix}\right)\end{split}\]
-
geotecha.speccon.integrals_generate_code.
EDload_linear_implementations
()[source]¶ Code generation for Integration of D[load(tau), tau] * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear.
Performs integrations involving a piecewise linear load. A 2d array of dimensions A[len(tvals), len(eigs)] is produced where the ‘i’th row of A contains the diagonal elements of the spectral ‘E’ matrix calculated for the time value tvals[i]. i.e. rows of this matrix will be assembled into the diagonal matrix ‘E’ elsewhere.
Paste the resulting code (at least the loops) into EDload_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. needs to be compiled with f2py
See also
geotecha.speccon.integrals.EDload_linear
- Resulting function.
geotecha.speccon.integrals.pEDload_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.edload_linear
- Resulting fortran function.
EDload_coslinear_implementations
- Similar function with additional cosine term.
Eload_linear_implementations
- Similar function but the time dependent loading function is not differentiated with respect to time.
Notes
Assuming the load are formulated as the product of separate time and depth dependant functions:
\[\sigma\left({Z,t}\right)=\sigma\left({Z}\right)\sigma\left({t}\right)\]the solution to the consolidation equation using the spectral method has the form:
\[u\left(Z,t\right)=\mathbf{\Phi v E}\left(\mathbf{\Gamma v}\right)^{-1}\mathbf{\theta}\]The matrix \(E\) is a time dependent diagonal matrix due to time dependant loadings. The version of \(E\) calculated here in EDload_linear is from loading terms in the governing equation that are NOT differentiated wrt \(t\). The diagonal elements of \(E\) are given by:
\[\mathbf{E}_{i,i}=\int_{0}^t{\frac{d{\sigma\left(\tau\right)}}{d\tau}{\exp\left({(dT\left(t-\tau\right)\lambda_i}\right)}\,d\tau}\]where
\(\lambda_i\) is the ith eigenvalue of the problem, \(dT\) is a time factor for numerical convienience, \(\sigma\left(\tau\right)\) is the time dependant portion of the loading function.When the time dependant loading term \(\sigma\left(\tau\right)\) is piecewise in time. The contribution of each load segment is found by:
\[\mathbf{E}_{i,i}=\int_{t_s}^{t_f}{{\sigma\left(\tau\right)}\exp\left({dT\left(t-\tau\right)*\lambda_i}\right)\,d\tau}\]where
\[t_s = \min\left(t,t_{increment\:start}\right)\]\[t_f = \min\left(t,t_{increment\:end}\right)\](note that this function,`EDload_linear`, rather than use \(t_s\) and \(t_f\), explicitly finds increments that the current time falls in, falls after, and falls before and treates each case on it’s own.)
Each \(t\) value of interest requires a separate diagonal matrix \(E\). To use space more efficiently and to facilitate numpy broadcasting when using the results of the function, the diagonal elements of \(E\) for each time value t value are stored in the rows of array \(A\) returned by EDload_linear. Thus:
\[\begin{split}\mathbf{A}=\left(\begin{matrix}E_{0,0}(t_0)&E_{1,1}(t_0)& \cdots & E_{neig-1,neig-1}(t_0)\\ E_{0,0}(t_1)&E_{1,1}(t_1)& \cdots & E_{neig-1,neig-1}(t_1)\\ \vdots&\vdots&\ddots&\vdots \\ E_{0,0}(t_m)&E_{1,1}(t_m)& \cdots & E_{neig-1,neig-1}(t_m)\end{matrix}\right)\end{split}\]
-
geotecha.speccon.integrals_generate_code.
Eload_coslinear_implementations
()[source]¶ Code generation for Integration of cos(omega*tau+phase)*load(tau) * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear.
Performs integrations involving a piecewise linear load. A 2d array of dimensions A[len(tvals), len(eigs)] is produced where the ‘i’th row of A contains the diagonal elements of the spectral ‘E’ matrix calculated for the time value tvals[i]. i.e. rows of this matrix will be assembled into the diagonal matrix ‘E’ elsewhere.
Paste the resulting code (at least the loops) into Eload_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. needs to be compiled with f2py
See also
geotecha.speccon.integrals.Eload_coslinear
- Resulting function.
geotecha.speccon.integrals.pEload_coslinear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.eload_coslinear
- Resulting fortran function.
Eload_linear_implementations
- Similar function with no cosine term.
EDload_coslinear_implementations
- Similar function but the time dependent loading function is differentiated with respect to time.
Notes
Assuming the load are formulated as the product of separate time and depth dependant functions:
\[\sigma\left({Z,t}\right)=\sigma\left({Z}\right)\sigma\left({t}\right)\]the solution to the consolidation equation using the spectral method has the form:
\[u\left(Z,t\right)=\mathbf{\Phi v E}\left(\mathbf{\Gamma v}\right)^{-1}\mathbf{\theta}\]The matrix \(E\) is a time dependent diagonal matrix due to time dependant loadings. The version of \(E\) calculated here in Eload_coslinear is from loading terms in the governing equation that are NOT differentiated wrt \(t\). The diagonal elements of \(E\) are given by:
\[\mathbf{E}_{i,i}=\int_{0}^t{{\cos\left(\omega\tau+\textrm{phase}\right)}{\sigma\left(\tau\right)}{\exp\left({(dT\left(t-\tau\right)\lambda_i}\right)}\,d\tau}\]where
\(\lambda_i\) is the ith eigenvalue of the problem, \(dT\) is a time factor for numerical convienience, \(\sigma\left(\tau\right)\) is the time dependant portion of the loading function.When the time dependant loading term \(\sigma\left(\tau\right)\) is piecewise in time. The contribution of each load segment is found by:
\[\mathbf{E}_{i,i}=\int_{t_s}^{t_f}{{\cos\left(\omega\tau+\textrm{phase}\right)}{\sigma\left(\tau\right)}\exp\left({dT\left(t-\tau\right)*\lambda_i}\right)\,d\tau}\]where
\[t_s = \min\left(t,t_{increment\:start}\right)\]\[t_f = \min\left(t,t_{increment\:end}\right)\](note that this function,`Eload_coslinear`, rather than use \(t_s\) and \(t_f\), explicitly finds increments that the current time falls in, falls after, and falls before and treates each case on it’s own.)
Each \(t\) value of interest requires a separate diagonal matrix \(E\). To use space more efficiently and to facilitate numpy broadcasting when using the results of the function, the diagonal elements of \(E\) for each time value t value are stored in the rows of array \(A\) returned by Eload_coslinear. Thus:
\[\begin{split}\mathbf{A}=\left(\begin{matrix}E_{0,0}(t_0)&E_{1,1}(t_0)& \cdots & E_{neig-1,neig-1}(t_0)\\ E_{0,0}(t_1)&E_{1,1}(t_1)& \cdots & E_{neig-1,neig-1}(t_1)\\ \vdots&\vdots&\ddots&\vdots \\ E_{0,0}(t_m)&E_{1,1}(t_m)& \cdots & E_{neig-1,neig-1}(t_m)\end{matrix}\right)\end{split}\]
-
geotecha.speccon.integrals_generate_code.
Eload_linear_implementations
()[source]¶ Code generation for Integration of load(tau) * exp(dT * eig * (t-tau)) between [0, t], where load(tau) is piecewise linear.
Performs integrations involving a piecewise linear load. A 2d array of dimensions A[len(tvals), len(eigs)] is produced where the ‘i’th row of A contains the diagonal elements of the spectral ‘E’ matrix calculated for the time value tvals[i]. i.e. rows of this matrix will be assembled into the diagonal matrix ‘E’ elsewhere.
Paste the resulting code (at least the loops) into Eload_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.Eload_linear
- Resulting function.
geotecha.speccon.integrals.pEload_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.eload_linear
- Resulting fortran function.
Eload_coslinear_implementations
- Similar function with additional cosine term.
EDload_linear_implementations
- Similar function but the time dependent loading function is differentiated with respect to time.
Notes
Assuming the load are formulated as the product of separate time and depth dependant functions:
\[\sigma\left({Z,t}\right)=\sigma\left({Z}\right)\sigma\left({t}\right)\]the solution to the consolidation equation using the spectral method has the form:
\[u\left(Z,t\right)=\mathbf{\Phi v E}\left(\mathbf{\Gamma v}\right)^{-1}\mathbf{\theta}\]The matrix \(E\) is a time dependent diagonal matrix due to time dependant loadings. The version of \(E\) calculated here in Eload_linear is from loading terms in the governing equation that are NOT differentiated wrt \(t\). The diagonal elements of \(E\) are given by:
\[\mathbf{E}_{i,i}=\int_{0}^t{{\sigma\left(\tau\right)}{\exp\left({(dT\left(t-\tau\right)\lambda_i}\right)}\,d\tau}\]where
\(\lambda_i\) is the ith eigenvalue of the problem, \(dT\) is a time factor for numerical convienience, \(\sigma\left(\tau\right)\) is the time dependant portion of the loading function.When the time dependant loading term \(\sigma\left(\tau\right)\) is piecewise in time. The contribution of each load segment is found by:
\[\mathbf{E}_{i,i}=\int_{t_s}^{t_f}{{\sigma\left(\tau\right)}\exp\left({dT\left(t-\tau\right)*\lambda_i}\right)\,d\tau}\]where
\[t_s = \min\left(t,t_{increment\:start}\right)\]\[t_f = \min\left(t,t_{increment\:end}\right)\](note that this function,`Eload_linear`, rather than use \(t_s\) and \(t_f\), explicitly finds increments that the current time falls in, falls after, and falls before and treates each case on it’s own.)
Each \(t\) value of interest requires a separate diagonal matrix \(E\). To use space more efficiently and to facilitate numpy broadcasting when using the results of the function, the diagonal elements of \(E\) for each time value t value are stored in the rows of array \(A\) returned by Eload_linear. Thus:
\[\begin{split}\mathbf{A}=\left(\begin{matrix}E_{0,0}(t_0)&E_{1,1}(t_0)& \cdots & E_{neig-1,neig-1}(t_0)\\ E_{0,0}(t_1)&E_{1,1}(t_1)& \cdots & E_{neig-1,neig-1}(t_1)\\ \vdots&\vdots&\ddots&\vdots \\ E_{0,0}(t_m)&E_{1,1}(t_m)& \cdots & E_{neig-1,neig-1}(t_m)\end{matrix}\right)\end{split}\]
-
class
geotecha.speccon.integrals_generate_code.
SympyVarsFor1DSpectralDerivation
(linear_var='z', slope=True)[source]¶ Bases:
object
Container for sympy vars, z, zt, zb, at, etc piecewise linear Spectral Galerkin integrations.
Parameters: linear_var : [‘z’, ‘x’, ‘y’], optional
Independent variable for the linear function specification. f(linear_var) = at+a_slope * (linear_var-linear_vart). Default linear_var=’z’.
slope : True/False, optional
If True (default), then the linear functions will be defined with a lumped slope term, e.g. a = atop + a_slope * (z - ztop) compared to if slope=False, where a = atop + (abot-atop)/(zbot-ztop)*(z-ztop). You will have to define a_slope in your code template, e.g. Python loops: a_slope = (ab[layer]-at[layer])/(zb[layer]-zt[layer]). Fortran loops: a_slope = (ab(layer)-at(layer)/(zb(layer)-zt(layer)). Vectorised: a_slope = (ab-at)/(zb-zt).
Examples
>>> v = SympyVarsFor1DSpectralDerivation() >>> v.a a_slope*(z - ztop) + atop >>> v.b b_slope*(z - ztop) + btop >>> v.c c_slope*(z - ztop) + ctop >>> v.map_to_add_index [(mi, m[i]), (mj, m[j]), (atop, at[layer]), (abot, ab[layer]), (btop, bt[layer]), (bbot, bb[layer]), (ctop, ct[layer]), (cbot, cb[layer]), (ztop, zt[layer]), (zbot, zb[layer])] >>> v.a.subs(v.map_to_add_index) a_slope*(z - zt[layer]) + at[layer] >>> v.b.subs(v.map_top_to_t_bot_to_b) b_slope*(z - zt) + bt >>> v.mi mi >>> v.mi.subs(v.map_to_add_index) m[i] >>> v.mi.subs(v.map_top_to_t_bot_to_b) mi
>>> v = SympyVarsFor1DSpectralDerivation(linear_var='x', slope=False) >>> v.a atop + (abot - atop)*(x - xtop)/(xbot - xtop)
Attributes
x, y, z (sympy.Symbol) Independent variables. xtop, xbot, ytop, ybot, ztop, zbot (sympy.Symbol) Symbols used in expressions to be integrated with sympy.integrate. After the integration these variables are usually replaced with the relevant xt, xb, yt etc. or xt[layer], yb[layer] etc. These substitutions can be made using map_to_add_index’ or `map_top_to_t_bot_to_b. i, j, k , layer (sympy.tensor.Idx) Index variables. xt, xb, yt, yb, zt, zb (sympy.tensor.IndexedBase) Variables for values at top and bottom of layer. Used to define linear relationships. These variable usually replace xtop, xbot after integrations. The reason they are not used before integration is thatsympy doesn’t seem to like the sympy.tensor.IndexedBase for integrations. Substitutions can be made using map_to_add_index’ or `map_top_to_t_bot_to_b. at, ab, a, a_slope: sympy.Symbol and sympy.Expr Variables to define linear relationships. If slope`=True, a = atop + a_slope * (z - ztop) If `slope`=False, a = atop + (abot - atop)/(zbot - ztop) * (z - ztop). Where z and ztop may change according to `linear_var. bt, bb, b, b_slope: sympy.Symbol and sympy.Expr Variables to define linear relationships. If slope`=True, b = atop + b_slope * (z - ztop) If `slope`=False, b = btop + (bbot - btop)/(zbot - ztop) * (z - ztop). Where z and ztop may change according to `linear_var. ct, cb, c, c_slope: sympy.Symbol and sympy.Expr Variables to define linear relationships. If slope`=True, c = ctop + c_slope * (z - ztop) If `slope`=False, c = ctop + (cbot - ctop)/(zbot - ztop) * (z - ztop). Where z and ztop may change according to `linear_var. map_to_add_index (list of 2 element tuples) A list to be used with the subs method of sympy expressions to add a index variables to the variables. A typical entries in map_to_add_index would be [(mi, m[i]), (mj, m[j]), (atop, at[layer]), (ztop, zt[layer]), ...]. Use this to after an integration invoving ztop, atop etc. to format the expression for use in function with loops. map_top_to_t_bot_to_b (list of 2 element tuples) A list to be used with the subs method of sympy expressions to add change ‘ztop’ to ‘zt’, ‘abot’ to ‘at’ etc. Typical entries in map_top_to_t_bot_to_b would be [(atop, at), (ztop, zt), ...]. Use this to after an integration invoving ztop, atop etc. to format the expression for use in a vectorised function. mi, mj (sympy.Symbol) Variable for row and column eigs. m (sympy.tensor.IndexedBase) IndexedBaseVariable of eigs. used for m[i], and m[j].
-
geotecha.speccon.integrals_generate_code.
dim1_ab_linear_between
()[source]¶ Code generation for Integrations of a(z) * b(z) between [z1, z2] where a(z) is a piecewise linear functions of z.
Calculates array A[len(z)]
Paste the resulting code (at least the loops) into piecewise_linear_1d.integrate_x1a_x2a_y1a_y2a_multiply_x1b_x2b_y1b_y2b_between.
Returns: fn : string
Python code with scalar (loops) implementation.
See also
Notes
The dim1sin_ab_linear_between, \(A\), is given by:
\[\mathbf{A}_{i}=\int_{z_1}^{z_2}{{a\left(z\right)}{b\left(z\right)}\,dz}\]where \(a\left(z\right)\) and \(b\left(z\right)\) are piecewise linear functions with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
dim1sin_DD_abDDf_linear_implementations
()[source]¶ Code generation for Integration of sin(mi * z) * D[a(z) * b(z) D[sin(mj * z),z,2],z,2] between ztop and zbot where a(z) and b(z) is piecewise linear functions of z.
Code is generated that will produce a square array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_abf_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_DD_abDDf_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_DD_abDDf_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_dd_abDddf_linear
- Resulting fortran function.
Notes
The dim1sin_DD_abDDf_linear matrix, \(A\) is given by:
\[\mathbf{A}_{i,j}=\int_{0}^1{\frac{d^2}{dz^2}\left({a\left(z\right)}{b\left(z\right)}\frac{d^2\phi_j}{dz^2}\right)\phi_i\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) and \(b\left(z\right)\) are piecewise linear functions with respect to \(z\), that within a layer is defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
To make the above integration simpler we integate by parts to get:
\[\mathbf{A}_{i,j}= \left.{\frac{d}{dz}\left({a\left(z\right)}{b\left(z\right)}\frac{d^2\phi_j}{dz^2}\right)\phi_i}\right|_{z=0}^{z=1} - \left.{{a\left(z\right)}{b\left(z\right)}\frac{d^2\phi_j}{dz^2}\frac{d\phi_i}{dz}}\right|_{z=0}^{z=1} +\int_{0}^1{{a\left(z\right)}{b\left(z\right)}\frac{d^2\phi_j}{dz^2}\frac{d^2\phi_i}{dz^2}\,dz}\]In this case the sine basis functions means the end point terms in the above equation are zero, leaving us with
\[\mathbf{A}_{i,j}= \int_{0}^1{{a\left(z\right)}{b\left(z\right)}\frac{d^2\phi_j}{dz^2}\frac{d^2\phi_i}{dz^2}\,dz}\]
-
geotecha.speccon.integrals_generate_code.
dim1sin_D_aDb_linear_implementations
()[source]¶ Code generation for Integrations of sin(mi * z) * D[a(z) * D[b(z), z], z] between ztop and zbot where a(z) is a piecewisepiecewise linear function of z, and b(z) is a linear function of z.
Code is generated that will produce a 1d array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_D_aDb_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Warning
The functions produced are set up to accept the b(z) input as piecewise linear, i.e. zt, zb, bt, bb etc. It is up to the user to ensure that the bt and bb are such that they define a continuous linear function. eg. to define b(z)=z+1 then use zt=[0,0.4], zb=[0.4, 1], bt=[1,1.4], bb=[1.4,2].
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_D_aDb_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_D_aDb_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_D_aDb_linear
- Resulting fortran function.
Notes
The dim1sin_D_aDb_linear which should be treated as a column vector, \(A\) is given by:
\[\mathbf{A}_{i}=\int_{0}^1{\frac{d}{dz}\left({a\left(z\right)}\frac{d}{dz}{b\left(z\right)}\right)\phi_i\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) is a piecewise linear functions with respect to \(z\), that within a layer is defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
\(b\left(z\right)\) is a linear function of \(z\) defined by
\[b\left(z\right) = b_t+\left({b_b-b_t}\right)z\]with \(t\) and \(b\) subscripts now representing ‘top’ and ‘bottom’ of the profile respectively.
Using the product rule for differentiation the above integral can be split into:
\[\mathbf{A}_{i}=\int_{0}^1{\frac{da\left(z\right)}{dz}\frac{db\left(z\right)}{dz}\phi_i\,dz} + \int_{0}^1{a\left(z\right)\frac{d^2b\left(z\right)}{dz^2}\phi_i\,dz}\]The right hand term is zero because \(b\left(z\right)\) is a continuous linear function so it’s second derivative is zero. The first derivative of \(b\left(z\right)\) is a constant so the left term can be integrated by parts to give:
\[\mathbf{A}_{i}=\frac{db\left(z\right)}{dz}\left( \left.\phi_i{a\left(z\right)}\right|_{z=0}^{z=1} - -\int_{0}^1{{a\left(z\right)}\frac{d\phi_i}{dz}\,dz} \right)\]
-
geotecha.speccon.integrals_generate_code.
dim1sin_D_aDf_linear_implementations
()[source]¶ Code generation for Integration of sin(mi * z) * D[a(z) * D[sin(mj * z),z],z] between ztop and zbot where a(z) is piecewise linear functions of z.
Code is generated that will produce a square array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_abf_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_D_aDf_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_D_aDf_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_d_adf_linear
- Resulting fortran function.
Notes
The dim1sin_D_aDf_linear matrix, \(A\) is given by:
\[\mathbf{A}_{i,j}=\int_{0}^1{\frac{d}{dz}\left({a\left(z\right)}\frac{d\phi_j}{dz}\right)\phi_i\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) is a piecewise linear functions with respect to \(z\), that within a layer is defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
To make the above integration simpler we integate by parts to get:
\[\mathbf{A}_{i,j}= \left.\phi_i{a\left(z\right)}\frac{d\phi_j}{dz}\right|_{z=0}^{z=1} -\int_{0}^1{{a\left(z\right)}\frac{d\phi_j}{dz}\frac{d\phi_i}{dz}\,dz}\]In this case the sine basis functions means the left term in the above equation is zero, leaving us with
\[\mathbf{A}_{i,j}= -\int_{0}^1{{a\left(z\right)}\frac{d\phi_j}{dz}\frac{d\phi_i}{dz}\,dz}\]
-
geotecha.speccon.integrals_generate_code.
dim1sin_a_linear_between
()[source]¶ Code generation for Integrations of sin(mi * z) * a(z) between [z1, z2] where a(z) is a piecewise linear functions of z.
Calculates array A[len(z), len(m)].
Paste the resulting code into dim1sin_a_linear_between.
Returns: fn : string
Python code with scalar (loops) implementation.
See also
geotecha.speccon.integrals.dim1sin_a_linear_between
- Resulting function.
geotecha.speccon.integrals.pdim1sin_a_linear_between
- Resulting function with PolyLine inputs.
Notes
The dim1sin_a_linear_between, \(A\), is given by:
\[\mathbf{A}_{i,j}= \int_{z_1}^{z_2}{{a\left(z\right)}\phi_j\,dz}\]where the basis function \(\phi_j\) is given by:
\[\phi_j\left(z\right)=\sin\left({m_j}z\right)\]and \(a\left(z\right)\) is a piecewise linear functions with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
dim1sin_ab_linear_implementations
()[source]¶ Code generation for Integration of sin(mi * z) * a(z) * b(z) between ztop and zbot where a(z) and b(z) are piecewise linear functions of z.
Code is generated that will produce a square array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_ab_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_ab_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_ab_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_ab_linear
- Resulting fortran function.
Notes
The dim1sin_ab_linear which should be treated as a column vector, \(A\) is given by:
\[\mathbf{A}_{i}=\int_{0}^1{{a\left(z\right)}{b\left(z\right)}\phi_i\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) and \(b\left(z\right)\) are piecewise linear functions with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
dim1sin_abc_linear_implementations
()[source]¶ Code generation for Integrations of sin(mi * z) * a(z) * b(z) * c(z) between ztop and zbot where a(z), b(z), c(z) are piecewise linear functions of z.
Code is generated that will produce a 1d array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_abc_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_abc_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_abc_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_abc_linear
- Resulting fortran function.
Notes
The dim1sin_abc_linear which should be treated as a column vector, \(A\) is given by:
\[\mathbf{A}_{i}=\int_{0}^1{{a\left(z\right)}{b\left(z\right)}{c\left(z\right)}\phi_i\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\), \(b\left(z\right)\), and \(c\left(z\right)\) are piecewise linear functions with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
dim1sin_abf_linear_implementations
()[source]¶ Code generation for Integration of sin(mi * z) * a(z) * a(z) * sin(mj * z) between ztop and zbot where a(z) is piecewise linear.
Code is generated that will produce a square array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_abf_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_abf_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_abf_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_abf_linear
- Resulting fortran function.
Notes
The dim1sin_abf_linear matrix, \(A\) is given by:
\[\mathbf{A}_{i,j}=\int_{0}^1{{a\left(z\right)}{b\left(z\right)}\phi_i\phi_j\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) and \(b\left(z\right)\) are piecewise linear functions with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
dim1sin_af_linear_implementations
()[source]¶ Code generation for Integration of sin(mi * z) * a(z) * sin(mj * z) between ztop and zbot where a(z) is piecewise linear.
Code is generated that will produce a square array with the appropriate integrals at each location.
Paste the resulting code (at least the loops) into dim1sin_af_linear.
Creates three implementations:
- ‘scalar’, python loops (slowest).
- ‘vectorized’, numpy (much faster than scalar).
- ‘fortran’, fortran loops (fastest). Needs to be compiled and interfaced with f2py.
Returns: fn : string
Python code with scalar (loops) and vectorized (numpy) implementations also calls the fortran version.
fn2 : string
Fortran code. Needs to be compiled with f2py.
See also
geotecha.speccon.integrals.dim1sin_af_linear
- Resulting function.
geotecha.speccon.integrals.pdim1sin_af_linear
- Resulting function with PolyLine inputs.
geotecha.speccon.ext_integrals.dim1sin_af_linear
- Resulting fortran function.
Notes
The dim1sin_af_linear matrix, \(A\) is given by:
\[\mathbf{A}_{i,j}=\int_{0}^1{{a\left(z\right)}\phi_i\phi_j\,dz}\]where the basis function \(\phi_i\) is given by:
\[\phi_i\left(z\right)=\sin\left({m_i}z\right)\]and \(a\left(z\right)\) is a piecewise linear function with respect to \(z\), that within a layer are defined by:
\[a\left(z\right) = a_t+\frac{a_b-a_t}{z_b-z_t}\left(z-z_t\right)\]with \(t\) and \(b\) subscripts representing ‘top’ and ‘bottom’ of each layer respectively.
-
geotecha.speccon.integrals_generate_code.
tw
(text, indents=3, width=100, break_long_words=False)[source]¶ Rough text wrapper for long sympy expressions
1st line will not be indented.
Parameters: text : str
Text to wrap
width : int optional
Rough width of warpping. Default width=100.
indents : int, optional
Multiple of 4 spaces that will be used to indent each line. Default indents=3.
break_long_words : True/False, optional
Default break_long_words=False.
Returns: out : str
Multi-line string.