jrenaud90 / TidalPy

Software suite to perform solid-body tidal dissipation calculations for rocky and icy worlds
Other
15 stars 3 forks source link

TidalPy.RadialSolver.solver missing after crash #50

Closed nlwagner closed 6 months ago

nlwagner commented 6 months ago

I'll try to detail the conditions that led up to this crash as best I can.

I was testing radial_solver with much finer layers and more property variations than previously. I'm currently using Python 3.9 and Spyder version 5.5.1 through conda.

After rebooting Spyder, however, I'm met with this error:

runfile('/Users/nlwagner25/Desktop/PYTHON/TidalPy/testing_AK_model_elastic.py', wdir='/Users/nlwagner25/Desktop/PYTHON/TidalPy')
2024-02-16 14:33:05(+00:00:28::286448) - INFO     : TidalPy initializing...
2024-02-16 14:33:05(+00:00:28::287662) - INFO     : TidalPy initialization complete.
Traceback (most recent call last):

  File ~/opt/anaconda3/envs/tidalpy/lib/python3.9/site-packages/spyder_kernels/py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File ~/Desktop/PYTHON/TidalPy/testing_AK_model_elastic.py:15
    from TidalPy.RadialSolver import radial_solver

  File ~/Desktop/PYTHON/TidalPy/TidalPy/RadialSolver/__init__.py:1
    from TidalPy.RadialSolver.solver import radial_solver

ModuleNotFoundError: No module named 'TidalPy.RadialSolver.solver'

I tried reinstalling TidalPy through Pip, but no luck. I'm completely deleting and recreating my conda environment and will update with a comment once that finishes.

nlwagner commented 6 months ago

After a clean conda environment install I'm receiving the same error.

nlwagner commented 6 months ago

After some testing, it seems this error is only within Spyder. Jupyter notebooks still work fine. Tested with the included demo notebooks within /Demos.

jrenaud90 commented 6 months ago

I will play around with spyder to see if I can run into the issue. I think my first question/concern is what led to that initial crash

jrenaud90 commented 6 months ago

Also, can you check what happens if you just run a script from the terminal in the conda environment where tidalpy is installed? So basically the same thing you'd do in Spyder but without being in spyder.

nlwagner commented 6 months ago

So running the script from the command line results in the same error:

$ python testing_AK_model_elastic.py                                                                                                                                                            
2024-02-22 11:52:32(+00:00:00::825509) - INFO     : TidalPy initializing...                                                                                                                     
2024-02-22 11:52:32(+00:00:00::825607) - INFO     : TidalPy initialization complete.                                                                                                            
Traceback (most recent call last):                                                                                                                                                              
  File "/Users/nlwagner25/Desktop/PYTHON/TidalPy/testing_AK_model_elastic.py", line 15, in <module>                                                                                             
    from TidalPy.RadialSolver import radial_solver                                                                                                                                              
  File "/Users/nlwagner25/Desktop/PYTHON/TidalPy/TidalPy/RadialSolver/__init__.py", line 1, in <module>                                                                                         
    from TidalPy.RadialSolver.solver import radial_solver                                                                                                                                       
ModuleNotFoundError: No module named 'TidalPy.RadialSolver.solver'                                                                                                                              
(TidalPy)

The best I can remember is I was just testing radial_solver for a model I had. The file is testing_AK_model_elastic.py in my forked repository if you can access it. It hasn't been modified since the crash.

In testing a new conda env I run the following:

 conda create -n tidalpy2 python="3.11" numpy spyder jupyter matplotlib scipy

 conda activate tidalpy2

 Pip install TidalPy

 python testing_AK_model_elastic.py 

The last line running the script results in the error posted before.

jrenaud90 commented 6 months ago

Hey @nlwagner!

Okay I think I have found a few issues.

Cheers,

jrenaud90 commented 6 months ago

Okay figured out the problem with the complex shear calculations. The arrays are not being passed as C-contiguous arrays. This is not documented but that is a requirement for all TidalPy functionality. The reason they are not is because of the reverse operation [::-1]. As I mentioned in the last post, you don't want to do that anyways, but if for some reason you did end up needing to do that make sure to convert the arrays to contiguous via:

shear_array = np.ascontiguousarray(shear_array)
viscosity_array = np.ascontiguousarray(viscosity_array)
elastic_rheology.vectorize_modulus_viscosity(forcing_frequency, shear_array, viscosity_array, complex_shear)

I will add some better warnings and documentation in the next patch to make this clear.

Let me know if these fixes helped!

nlwagner commented 6 months ago

Thanks so much Joe. Sorry for the late reply, been focusing on LPSC related things. I followed your advice and I now have it working! I'm glad it was a simple issue. I definitely misunderstood the layer types input, I thought that had to be the same size as my input array.

I'll let you know if I run into any other errors I can't overcome :)