Skip to content

Using numexpr and/or einsumt inside form definitions #665

Answered by adtzlr
bhaveshshrimali asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @bhaveshshrimali!

Of course, feel free to use all packages you like inside your functions as long as you return numpy arrays.

There is a typo in Js, it should be:

def F2(F, p, mu, lmbda):
    J = det(F)
    Js = nev(
        "0.5 * (lmbda + p + 2.0 * (lmbda * mu + 0.25 * (lmbda + p) ** 2)**(0.5)) / lmbda"
    )
    dJsdp = nev(
        "(0.25 * lmbda + 0.25 * p + 0.5 * (lmbda * mu + 0.25 * (lmbda + p) ** 2))**(0.5) / (lmbda * (lmbda * mu + 0.25 * (lmbda + p) ** 2)**(0.5))"
    )
    ans = nev("J - (Js + (p + mu / Js - lmbda * (Js - 1)) * dJsdp)")
    return ans

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bhaveshshrimali
Comment options

Answer selected by bhaveshshrimali
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants