Skip to contents

add_element() adds a new element to an aem object.

remove_element() removes an element from an aem object based on its name or type.

Usage

add_element(aem, element, name = NULL, solve = FALSE, ...)

remove_element(aem, name = NULL, type = NULL, solve = FALSE, ...)

Arguments

aem

aem object.

element

analytic element of class element.

name

optional name of the element as character. Duplicate element names in aem are not allowed..

solve

logical, should the model be solved after adding or removing the element? Defaults to FALSE.

...

ignored

type

class of the element(s) to remove. Either name or type should be specified in remove_element().

Value

The aem model with the addition of element or with the removal of element(s). If solve = TRUE, the model is solved using solve.aem(). The name of the new element is taken from the name argument, the object name or set to element_1 with 1 being the index of the new element in the element list. See examples.

See also

Examples

m <- aem(k = 10, top = 10, base = 0, n = 0.2)
mnew <- add_element(m, constant(xc = 0, yc = 1000, hc = 12), name = 'rf')

# if name not supplied, tries to obtain it from object name
rf <- constant(xc = 0, yc = 1000, hc = 12)
mnew <- add_element(m, rf)

# or else sets it sequentially from number of elements
mnew <- add_element(m, constant(xc = 0, yc = 1000, hc = 12))

# add_element() adn remove_element() are pipe-friendly
mnew <- aem(k = 10, top = 10, base = 0, n = 0.2) |>
    add_element(rf, name = 'rf') |>
    add_element(headwell(xw = 0, yw = 100, rw = 0.3, hc = 8),
                name = 'headwell', solve = TRUE)

# removing elements
mnew <- remove_element(mnew, name = 'rf')
mnew <- remove_element(mnew, type = 'headwell')