Matrix-Multiplication CoefficientFunction * NumPy

More
3 years 11 months ago #3276 by Tele
Hi,

I am sorry I have to bring up this topic again, but everything worked flawlessly besides some minor issues I encountered with the stresses around the undeformed state. Here the stresses computed from NGSolve are somewhat different compared to the results I obtain by using the same Matrizes using the origninal tensorflow network. However this is only the case around the undeformed state for larger deformations everything works fine again. I have attached an Image to illustrate the behaviour the blue and orange lines can be ignored they are some test data I use from other sources. Important are the red (NGSolve Simulation) and the green (Tensorflow Prediciton) data. I made sure this is no issue on the meshing by refining the mesh in size, order and a combination thereof. All result in the same data. Then I tried refining the steps I use to plot the data to see wether the linearization might result in some issues, but this also resulted in no changes. Lastly I wanted to see whether the Energy Density computed is the issue or whether the differentiation of said Energy Density.

Now I tried to evaluate the Energy Density function I am using to solve the Problem by generating a CoefficientFunction and evaluating it on the net, just I have done it with the stresses. However, this results in the error
Code:
File "<string>", line 91, in <module> netgen.libngpy._meshing.NgException: MultMatMatCF:: scalar evaluate for matrix called
This error is not reproducable with the NeoHookean example in the WTA section of the Documentation, so I believe it to be an issue with the Matrix-Multiplication I am using, I sadly didn't find any further details on how the error is happening, but I attached a file wich reproduces the error.

I am using
Code:
NGSolve-6.2.2008-78-ga51abb5db
in order to enable differentiation of vector-valued functions as mentioned above.

Thank you again for all your help, should you need anything more from me, just let me know!

Best,
Til

File Attachment:

File Name: trials_ngF...11-01.py
File Size:3 KB

This browser does not support PDFs. Please download the PDF to view it: Download PDF

More
3 years 11 months ago #3277 by joachim
replace line 91 by
Code:
W_sim.append(W[0,0](eval_point))
we distinguish between scalars and 1x1 matrices.

I also fixed the cf(eval_point) to allow vectors and matrices of dimension 1.

It's difficult to help with the difference between direct simulation and the tensorflow approximation without having the example.

Joachim
The following user(s) said Thank You: Tele
More
3 years 11 months ago #3278 by Tele
Hi Joachim,

thanks a lot for the quick answer.
I am left with just one minor question: If I need to distinguish between scalars and 1x1 matrices the "cleaner" way to return the energy desinty would be to write
Code:
return W[0,0]
instead of
Code:
return W
in line 37 of my example file?

Regarding the differences between the NGSolve simulation and my Tensorflow model I am still investigating where exactly the error is sourced. The Problem I encountered while doing this was the problem with the evaluation of 1x1 matrizes. I was able to compare the energy density of both approaches now and recognized, that the tensorflow model does not result in an energy density of 0 at an undeformed state, which is most likely the reason behind this inconsistencies between the two approaches. I am sorry if I made the impression there would be something wrong with NGSolve in this case. I just wanted to give some background on how I encountered the error.

Thank you again!
Stay healthy and best regards,
Til
Time to create page: 0.121 seconds