MiroK / fenics-calc

Calculator over FEniCS functions
MIT License
1 stars 3 forks source link

No module named 'interpreter' #2

Closed thw1021 closed 4 years ago

thw1021 commented 4 years ago

@MiroK Hi, Miroslav. Thanks for your work. I want to use this code to do some calculations, but I meet an error as : Screenshot from 2019-12-26 10-51-33

Is there any requirement for the version of fenics ? I am using fenics 2018.1.0 (python3). I make a small modification to install fenics-xalc by python3.

Could you give me some suggestions, please ?

MiroK commented 4 years ago

Hi, did you use the python3 brach or master?

thw1021 commented 4 years ago

master.

Sorry, will try python branch now.

thw1021 commented 4 years ago

Same problems.

thw1021 commented 4 years ago

When I use fenics 2017.2.0.r4 (python2), the problem disappeared. But there is a new problem: Screenshot from 2019-12-26 17-25-38

thw1021 commented 4 years ago

The code is given by @jerabaul29

from xcalc.timeseries import PVDTempSeries
from xcalc.timeseries import clip
from xcalc.interpreter import Eval
from xcalc.operators import Mean, RMS, STD
from dolfin import *

print("Hi there!")

list_path_to_data = ["./Re_100/results", "./Re_200/results", "./Re_300/results", "./Re_400/results"]

for what in ['velocity', 'pressure']:
    for path_to_data in list_path_to_data:

        print("snippet applied on {} for path {}".format(what, path_to_data))

        if what == 'pressure':
            data_to_analyze = PVDTempSeries('%s/p_out.pvd' % path_to_data, FiniteElement('Lagrange', triangle, 1))

        elif what == 'velocity':
            # I chose to look here at velocity magniture, pod of velocity field shoudl work as well
            velocity = PVDTempSeries('%s/u_out.pvd' % path_to_data, VectorElement('Lagrange', triangle, 1))
            data_to_analyze = Eval(sqrt(inner(velocity, velocity)))

        first_dump = 600
        last_dump = 1199

        clipped_data_to_analyze = clip(data_to_analyze, first_dump, last_dump)

        computed_mean = Mean(clipped_data_to_analyze)

        out = File('%s/mean_rms/mean_%s.pvd' % (path_to_data, what))
        computed_mean.rename('f', '0')
        out << (computed_mean, 0.)

        computed_rms = RMS(clipped_data_to_analyze)

        out = File('%s/mean_rms/rms_%s.pvd' % (path_to_data, what))
        computed_rms.rename('f', '0')
        out << (computed_rms, 0.)

        computed_std = STD(clipped_data_to_analyze)

        out = File('%s/mean_rms/std_%s.pvd' % (path_to_data, what))
        computed_std.rename('f', '0')
        out << (computed_std, 0.)
thw1021 commented 4 years ago

OK. Now there is no error. But the variables in output files are all zero. Do you know the reason @MiroK ?

(Sorry for bothering during holidays.)

MiroK commented 4 years ago

Hi, what is the fenics version, fenics-calc branch that you are using? Do the tests pass on your installation? Finally, could you provide a minimal code example which I can use to reproduce the problem with zeros?

On 26 Dec 2019, at 16:43, thw1021 notifications@github.com wrote:

 OK. Now there is no error. But the variables in output files are all zero. Do you know the reason @MiroK ?

(Sorry for bothering during holidays.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

thw1021 commented 4 years ago

@MiroK Thanks for your help.

fenics: 2017.1.0 branch: master python version: python 2.7.12

I run the test for operators by python -m unittest test_operators and it seems no problem.

sample code: see https://github.com/MiroK/fenics-calc/issues/2#issuecomment-569025670

sample data: you can use the data of your JFM paper.

I run all code in docker (docker pull quay.io/fenicsproject/stable:2017.1.0)

thw1021 commented 4 years ago

OK. I may know the reason. There may be something wrong with your new push compared with https://github.com/jerabaul29/fenics-calc (The sample code can run well with this repo).

In addition, as a summary, I would like to make some notes here:

  1. This code is only compatible with fenics 2017.1.0 (maybe 2017.2.0 is OK, no sure.)
    • docker pull quay.io/fenicsproject/stable:2017.1.0
  2. Using pip install --no-binary=h5py h5py to install h5py. Otherwise it will fail.
  3. For DMD analysis, do as following:

Note: do step 2 and 3 in root mode.