Git Product home page Git Product logo

hyperjet's People

Contributors

oberbichler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hyperjet's Issues

AttributeError: module 'hyperjet' has no attribute 'Jet'

Hello,

I am trying to follow your quickstart.md but I find this error. could you please help me?

I have installed with

>> pip install git+https://github.com/oberbichler/HyperJet

then

In [2]: import hyperjet as hj

In [3]: x, y = hj.Jet.variables([3, 6])
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-1bbea4a89a88> in <module>
----> 1 x, y = hj.Jet.variables([3, 6])

AttributeError: module 'hyperjet' has no attribute 'Jet'

Thanks

Sqrt of 0.0

const auto g = m_g / (2 * f);

Have you tried what happens if one takes the square root of 0.0?

>>> import hyperjet as hj
>>> a = hj.Jet(0.0, [1])
>>> np.sqrt(a)
__main__:1: RuntimeWarning: divide by zero encountered in sqrt
Jet<0.000000>

I'm not sure if this Warning is caused by the division by 0.0 inside the Jet implementation or somewhere in numpy.

Armin

[Question]: Performance considerations on evaluating hessians of large inputs

Hi,

I'm always looking for alternative backends beside casADi for my constitutive material definition python package (matADi, ideas on alternative backends here) and I really like hyperjet, thanks ๐Ÿ…! Given the example below, do you have any other ideas to speed things up? My use case is to evaluate gradients and hessian of a strain energy function for hyperelastic solids within finite element analyses (using FElupe).

import numpy as np
from hyperjet import DDScalar

def det(A):
    return (
        A[0] * A[1] * A[2] + 2 * A[3] * A[4] * A[5]
        - A[1] * A[5] ** 2 - A[0] * A[4] **2 - A[2] * A[3] ** 2
    )

def trace(A):
    return A[:3].sum()

def neo_hooke(C):
    return det(C) ** (-1 / 3) * trace(C) - 3

def tensor(x):
    return np.array(DDScalar.variables(x.ravel())).reshape(*x.shape)

# init 100,000 random right Cauchy-Green deformation tensors
rCG = (np.random.rand(100000, 6) - 0.5) / 5
rCG[:, :3] += 1
    
from joblib import Parallel, delayed

hessian = lambda fun, x: fun(tensor(x)).hm()
A = Parallel(n_jobs=16, verbose=1, batch_size=1000)(
    delayed(hessian)(neo_hooke, C) for C in rCG#
)

gives

[Parallel(n_jobs=16)]: Using backend LokyBackend with 16 concurrent workers.
[Parallel(n_jobs=16)]: Done 18032 tasks      | elapsed:    0.9s
[Parallel(n_jobs=16)]: Done 97760 tasks      | elapsed:    3.0s
[Parallel(n_jobs=16)]: Done 100000 out of 100000 | elapsed:    3.1s finished

which is very ok but I'd like to know if there is room for improvement. Not in using joblib, but some best-practise tips for hyperjet instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.