Internals

Warning

This section documents functions and structures that are not part of Muscades or Muscade.Toolbox's public API. These are neither intended to be used by developers of Muscade-based applications nor by users such of applications. Interface changes can occur at any time.

Muscade

Muscade.IdVecType

An "identity vector"

id = IdVec i = 9834987 id[i] == i # true for any i

See also Julia's identity function.

source
Muscade.OffsetVectorType

A simple offset vector that only implements "setindex!" and "getindex". Based on Memory, so cannot be extended.

source
Muscade.addin!Method
Muscade.addin!(asm,global,block,ibr,ibc,factor=1.)

Add a sparse block into a large out sparse matrix, at block-row and -column ibr and ibc. Use prepare to allocate memory for global and build the assembler asm.

source
Muscade.addin!Method
addin!(asm,outvec,blockvec,ibr)

Add a full block vector into a large outvec full vector. at block-row ibr. Use prepare to create asm.

See also: prepare

source
Muscade.geneigType
λ,v,ncv = Muscade.geneig{ALGO}(A,B,neig=5)

Solves (A-λ*B)*v=0, finding the neig lowest eigenvalues λ (in absolute value) and the corresponding eigenvectors v (a Vector{Vector})

Input

ALGO can be

  • :SDP if A is symmetric definite positive and B is symmetric. Will return real λ and v.
  • :Hermitian if A is symmetric indefinite and B is symmetric. Will return real λ and v.
  • :Complex otherwise, will return complex λ and v.

Optional keyword arguments:

  • maxiter = 300
  • verbosity = 0 ∈ {0,1,2,3}
  • krylovdim = 2neig+6

Uses KrylovKit.jl. Freely based on VibrationGEPHelpers.jl and input from PetrKryslUCSD and stevengj. See GIThub-blame for bug-credits.

source
Muscade.to_orderType
to_order{P,N}(V)

Decrease (lossy) or increase (pad partials with zeros) the order of differentiation of V. V is a nested structure of NamedTuple, Tuple, SArray, and the components of V must be of type ∂ℝ or 𝕣.

IMPORTANT:

  1. assumes all the nested differentiations are with respect to the same variable.
  2. to_order{P,N}(V::𝕣) = V
source
Muscade.variate_Method
X = variate_{P,N}(x)

where typeof(x)<:SVector{N}, create a SVector of automatic differentiation objects of precedence P.

X = variate_{P}(x)

where typeof(x)<:Real, create an object of precedence P.

!!! Warning Improper use may cause perturbation confusion. Assumes, without testing, that precedence(x)=P-1

See also: precedence, δ_, value, , VALUE, value_∂

source
Muscade.δ_Method
X = δ_{P,N,R}()

create a SVector of automatic differentiation objects of precedence P and value zero.

X = δ_{P}()

Create automatic differentiation object of precedence P and value zero.

!!! Warning Improper use may cause perturbation confusion

See also: precedence, Muscade.variate_, value, , VALUE, value_∂

source
Muscade.ℕType
ℕ (\bbN)

an alias for UInt64. For use in dispatching. ℕ1... ℕ4 are AbstractArrays of dimensions 1 to 4.

source
Muscade.𝕔Type
𝕔 (\bbc)

an alias for Complex{Float64}. For use in struct definitions. 𝕔1... 𝕔4 are Arrays of dimensions 1 to 4. 𝕔11 is a Vector of Vector.

source
Muscade.𝕟Type
𝕟 (\bbn)

an alias for UInt64. For use in struct definitions. 𝕟1... 𝕟4 are Arrays of dimensions 1 to 4.

source
Base.copyMethod
s2 = copy(s1::State)

Copy a state so that s1 and s2 do not share memory.

(Actualy the States will stil share the same Model, but no operations are provided to mutate it).

s2 = copy(s1;[time=t])

create a copied State with time t.

See also: initialize!, setdof!

source
Muscade.eletypMethod
et = eletyp(model)

Return a vector of the concrete types of elements in the model.

source
Muscade.indentMethod
str = indent(str,n)

Add n spaces at the begining of every line in str.

source
Muscade.isapprox_dbgMethod
Muscade.isapprox_dbg(a,b;kwargs...)

Compare two ∂ℝ of the same type (or two conformant AbstractArrays of same eltype). The comparison applies to the value and the partial derivatives.

This differs from

isapprox(a,b;kwargs...)

which only compares values, in keeping with the principle that ∂ℝ must behave as .

source
Muscade.prepareMethod
bigmat,bigmatasm,bigvecasm,bigvecdis = Muscade.prepare(pattern)

Prepare for the assembly of sparse blocks into a large sparse matrix. bigmat is allocated, with the correct sparsity structure, but its nzval undef'ed. Where some blocks share the same sparsity structure, blocks in pattern can have === elements.

pattern is a SparseMatrixCSC{<:SparseMatrixCSC}, where empty blocks are structuraly zero

See also: addin!

source
Muscade.sinc1Method
Muscade.sinc1(x)

sinc1(x) = sin(x)/x - but sinc1(0.) = 1.. The function can be differentiated to the fourth order.

This differs from Julia's sinc(x) = sin(π*x)/(π*x).

source
Muscade.sparser!Method
sparser!(S::SparseMatrixCSC,keep::Function)

Eliminate terms that do not satisfy a criteria from the storage of a sparse matrix. S will be mutated, and the size of its internal storage modified. keep is a Function which to an index into S.nzval associate true if storage is to be kept for this term and false otherwise. Alternatively, keep can be a Vector{Bool}

Examples

sparser!([T],S,i->abs(S.nzval[i])>tol)
sparser!([T],S,keep::Vector{Boolean})

If T is provided (initialised as T = copy(S)), then result is set in T, S is unchanged, other wise S is mutated in place. The input keep::Vector{Boolean} must be of length nnz(S).

sparser!([S1,S2,...],rtol=1e-9)

Operates in place, reducing the sparses S1, S2 etc... to a common sparsity pattern.

Warning

In the first example, the keep function accesses S.nzval[i], and the term is then mutated by sparser!. Any criteria requiring multiple access to nzval must build a Vector before calling sparser!.

Warning

Note that assemble! computes the nzval of a sparse, assumning that its sparsity structure colptr and rowval is unchanged since sparse storage was allocated by asmmat in prepare. In other words, if applying sparser! directly to a sparse returned by assemble!, assemble! can no longer be called for this matrix.

source
Muscade.symmetric!Method
sA = symmetric!(A)

Compute the symmetric part of a square Matrix. Mutates the input argument.

source
Muscade.variate_indicesMethod
iV   = variate_indices(V)

For use in conjunction with

TV   = variate(V)

iV has the same structure as V and TV but contains integers: the indices into the partials of TV

See also: revariate

source
Muscade.zero!Method
zero!(a)

Set to zero all elements of an arrays. If a is sparse, the vector nzval of values is set to zero and the sparsity structure is unchanged.

source
Muscade.𝕫log2Method
𝕫log2(i::𝕫)

Compute the integer log2 of an integer, fast. Fails if i is not a power of two.

source

Muscade.Toolbox

Muscade.Toolbox.vec3Method
vec3(v, ind)

Create a 3-element static vector from selected elements of vector v.

Arguments

  • v: The input vector from which elements are selected.
  • ind: A collection of 3 indices specifying which elements of v to include.

Returns

  • An SVector{3} containing the elements v[ind[1]], v[ind[2]], v[ind[3]].
source
Muscade.allocate_drawingMethod

Drawing a Bar3D.

draw!(axis,state)

Optional arguments (and their default values) are

  • line_color = :black color of the line
  • Udof (true iff element has Udofs) wether to draw U-forces.
  • Uscale = 1. How many meter is a Newton per meter?
source
Muscade.allocate_drawingMethod

Drawing a EulerBeam3D.

draw!(axis,state)

draw!(axis,state;EulerBeam3D=(;style=:shape))

α      = 2π*(0:19)/20
circle = 0.1*[cos.(α) sin.(α)]'
draw!(axis,state;EulerBeam3D=(;style=:solid,section = circle))

style=:shape shows the deformed neutral axis of the element. It has optional arguments frame=true (draws the element's corotated frame of reference) and nseg=10 (number of points to show the deflected shape of each element).

style=:solid shows the deformed shape of the element. It requires the input section=... to be given a matrix of size (2,nsec) describing nsec points around the cross section of the element (no need to close the circumference by repeating the first point at the end). It has optional arguments nseg=10 as above, marking=true to draw a longitudinal marking and solid_color=:yellow.

Other optional arguments (and their default values) are

  • Udof (true iff element has Udofs) wether to draw U-forces.
  • draw_frame = false wether to draw the local reference frame of each element
  • draw_marking = true wether to draw "longitudinal marking" along the element. Will only draw if style=:solid.
  • nseg = 1 number of segments to display the shape of a deformed element
  • solid_color = :yellow color of the surface if style=:solid
  • line_color = :black color of the line if style=:sshape
  • Uscale = 1. How many meter is a Newton per meter?
source