Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FloatingPointError: invalid value encountered in sqrt #362

Open
xxu99 opened this issue Jul 29, 2023 · 12 comments
Open

FloatingPointError: invalid value encountered in sqrt #362

xxu99 opened this issue Jul 29, 2023 · 12 comments
Labels

Comments

@xxu99
Copy link

xxu99 commented Jul 29, 2023

Building PML boundaries [main_grid]: 0%| | 0/4 [00:00<?, ?it/s]Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in run_code
File "d:\doctor\gpr\gprmax\gprMax_main
.py", line 6, in
gprMax.gprMax.cli()
File "d:\doctor\gpr\gprmax\gprMax\gprMax.py", line 195, in cli
results = run_main(args)
^^^^^^^^^^^^^^
File "d:\doctor\gpr\gprmax\gprMax\gprMax.py", line 224, in run_main
results = context.run()
^^^^^^^^^^^^^
File "d:\doctor\gpr\gprmax\gprMax\contexts.py", line 79, in run
model.build()
File "d:\doctor\gpr\gprmax\gprMax\model_build_run.py", line 74, in build
self.reuse_geometry() if config.get_model_config().reuse_geometry else self.build_geometry()
^^^^^^^^^^^^^^^^^^^^^
File "d:\doctor\gpr\gprmax\gprMax\model_build_run.py", line 191, in build_geometry
gb.build_pmls()
File "d:\doctor\gpr\gprmax\gprMax\model_build_run.py", line 364, in build_pmls
build_pml(self.grid, pml_id, thickness)
File "d:\doctor\gpr\gprmax\gprMax\pml.py", line 707, in build_pml
pml.calculate_update_coeffs(averageer, averagemr)
File "d:\doctor\gpr\gprmax\gprMax\pml.py", line 291, in calculate_update_coeffs
cfs.calculate_sigmamax(self.d, er, mr, self.G)
File "d:\doctor\gpr\gprmax\gprMax\pml.py", line 95, in calculate_sigmamax
self.sigma.max = (0.8 * (m + 1)) / (config.sim_config.em_consts["z0"] * d * np.sqrt(er * mr))
^^^^^^^^^^^^^^^^
FloatingPointError: invalid value encountered in sqrt

@xxu99 xxu99 closed this as completed Jul 29, 2023
@xxu99 xxu99 reopened this Jul 31, 2023
@xxu99 xxu99 changed the title when we setup the 4.0,we meet FloatingPointError: invalid value encountered in sqrt when we use the 4.0,we meet FloatingPointError: invalid value encountered in sqrt Jul 31, 2023
@craig-warren
Copy link
Member

@xxu99 can you post the input file you are using that is causing this error please.

@craig-warren craig-warren changed the title when we use the 4.0,we meet FloatingPointError: invalid value encountered in sqrt FloatingPointError: invalid value encountered in sqrt Jul 31, 2023
@woiler103
Copy link

I get this error too. A little research has shown that er has a negative value. Is the pml_average_er_mr function working incorrectly?

@craig-warren
Copy link
Member

@woiler103 can you provide an input file you are using that creates the error. Thanks.

@woiler103
Copy link

So far this error is no longer showing up after update gprMax-devel today. Great, thanks!

@xxu99
Copy link
Author

xxu99 commented Sep 13, 2023

This problem still arises from time to time, I am running the cylinder_fs.py demo file.

@craig-warren
Copy link
Member

@xxu99 can you be more specific please to help us investigate.

@woiler103
Copy link

Today when running my configuration, this error appeared again. I ran cylinder_fs.py, the error also appears.
I add print("er = ", er) to pml.py
I think 'er' has an abnormal value.

--- Model 1/1, input file: c:\gprMax\examples\subgrids\cylinder_fs.py ---------------------------------------------------------------------------------------------

Model title: cylinder_fs.py
Spatial discretisation: 0.005 x 0.005 x 0.005m
Domain size: 0.5 x 0.5 x 0.5m (100 x 100 x 100 = 1e+06 cells)
Mode: 3D
Time step (at CFL limit): 9.62917e-12 secs
Time window: 6e-09 secs (625 iterations)
Waveform mypulse of type gaussiandot with maximum amplitude scaling 1, frequency 1.5e+09Hz created.
Hertzian dipole with polarity z at 0.205m, 0.4m, 0.25m, using waveform mypulse created.
Receiver at 0.245m, 0.4m, 0.25m with output component(s) Ex, Ey, Ez, Hx, Hy, Hz created.
Snapshot from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, at 5.10346e-10 secs with field outputs Ex, Ey, Ez, Hx, Hy, Hz and filename cylinder_fs_1.vti will be created.
Snapshot from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, at 1.51178e-09 secs with field outputs Ex, Ey, Ez, Hx, Hy, Hz and filename cylinder_fs_2.vti will be created.
Snapshot from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, at 2.51321e-09 secs with field outputs Ex, Ey, Ez, Hx, Hy, Hz and filename cylinder_fs_3.vti will be created.
Snapshot from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, at 3.50502e-09 secs with field outputs Ex, Ey, Ez, Hx, Hy, Hz and filename cylinder_fs_4.vti will be created.
Snapshot from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, at 4.50645e-09 secs with field outputs Ex, Ey, Ez, Hx, Hy, Hz and filename cylinder_fs_5.vti will be created.
Geometry view from 0m, 0m, 0m, to 0.5m, 0.5m, 0.5m, discretisation 0.005m, 0.005m, 0.005m, with filename base cylinder_fs created.
[sg] Material water with eps_r=4.9, sigma=0 S/m; mu_r=1, sigma*=0 Ohm/m created.
[sg] Debye disperion added to water with delta_eps_r=73.34, and tau=8.099e-12 secs created.
[sg] Geometry view from 0.215m, 0.24m, 0.1m, to 0.235m, 0.26m, 0.4m, discretisation 0.001m, 0.001m, 0.001m, with filename base cylinder_fs_sg created.
[sg] Cylinder with face centres 0.225m, 0.25m, 0.1m and 0.225m, 0.25m, 0.4m, with radius 0.01m, of material(s) water created, dielectric smoothing is off.

[sg] Ratio: 1:5
[sg] Spatial discretisation: 0.001 x 0.001 x 0.001m
[sg] Extent (working region): 0.215m, 0.24m, 0.1m to 0.23500000000000001m, 0.26m, 0.4m ((20 x 20 x 300 = 120000 cells)
[sg] Time step: 1.92583e-12 secs

Memory required (estimated): ~388.2 MB [main_grid] + ~253.4 MB [sg] + ~65.0 MB overhead = 706.6 MB

PML boundaries [main_grid]: {formulation: HORIPML, order: 1, thickness (cells): 10}
Building PML boundaries [main_grid]:   0%|                                                                                                   | 0/6 [00:00<?, ?it/s]
 er  =  -2.417486343256283e+22

Traceback (most recent call last):
  File "c:\gprMax\examples\subgrids\cylinder_fs.py", line 99, in <module>
    gprMax.run(scenes=[scene], n=1, geometry_only=False, outputfile=fn, subgrid=True, autotranslate=True)
  File "C:\gprMax\gprMax\gprMax.py", line 159, in run
    run_main(args)
  File "C:\gprMax\gprMax\gprMax.py", line 219, in run_main
    results = context.run()
              ^^^^^^^^^^^^^
  File "C:\gprMax\gprMax\contexts.py", line 79, in run
    model.build()
  File "C:\gprMax\gprMax\model_build_run.py", line 74, in build
    self.reuse_geometry() if config.get_model_config().reuse_geometry else self.build_geometry()
                                                                           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\gprMax\gprMax\model_build_run.py", line 191, in build_geometry
    gb.build_pmls()
  File "C:\gprMax\gprMax\model_build_run.py", line 368, in build_pmls
    build_pml(self.grid, pml_id, thickness)
  File "C:\gprMax\gprMax\pml.py", line 703, in build_pml
    pml.calculate_update_coeffs(averageer, averagemr)
  File "C:\gprMax\gprMax\pml.py", line 307, in calculate_update_coeffs
    cfs.calculate_sigmamax(self.d, er, mr, self.G)
  File "C:\gprMax\gprMax\pml.py", line 99, in calculate_sigmamax
    self.sigma.max = (0.8 * (m + 1)) / (config.sim_config.em_consts["z0"] * d * np.sqrt(er * mr))
                                                                                ^^^^^^^^^^^^^^^^
FloatingPointError: invalid value encountered in sqrt
Building PML boundaries [main_grid]:   0%|

My conda info:

(gprMax-devel) C:\gprMax>conda info
     active environment : gprMax-devel
    active env location : C:\miniconda3\envs\gprMax-devel
            shell level : 2
       user config file : C:\Users\tvm\.condarc
 populated config files :
          conda version : 23.7.3
    conda-build version : not installed
         python version : 3.11.4.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : c:\miniconda3  (writable)
      conda av data dir : c:\miniconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : c:\miniconda3\pkgs
                          C:\Users\tvm\.conda\pkgs
                          C:\Users\tvm\AppData\Local\conda\conda\pkgs
       envs directories : c:\miniconda3\envs
                          C:\Users\tvm\.conda\envs
                          C:\Users\tvm\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.7.3 requests/2.31.0 CPython/3.11.4 Windows/10 Windows/10.0.19043
          administrator : True
             netrc file : None
           offline mode : False

@DragonLT
Copy link

I also got this error after updating the recent script.
But I have tried to fixed this problem by inserting np.abs before er * mr in line 98 of gprMax\pml.py,

self.sigma.max = (0.8 * (m + 1)) / (config.sim_config.em_consts["z0"] * d * np.sqrt(np.abs(er * mr)))

and then the subgrids example cylinder_fs.py run correctly and got the results (h5 and vti format).
I'm not sure whether the upmentioned correction is right or wrong. Please check this.

@DragonLT
Copy link

Following is the result.
_-_Rx(49,80,50)

I also got this error after updating the recent script. But I have tried to fixed this problem by inserting np.abs before er * mr in line 98 of gprMax\pml.py,

self.sigma.max = (0.8 * (m + 1)) / (config.sim_config.em_consts["z0"] * d * np.sqrt(np.abs(er * mr)))

and then the subgrids example cylinder_fs.py run correctly and got the results (h5 and vti format). I'm not sure whether the upmentioned correction is right or wrong. Please check this.

@xxu99
Copy link
Author

xxu99 commented Sep 25, 2023

@DragonLT ,yeah,I'm not sure whether the upmentioned correction is right or wrong.I handled it the same way you did.But I haven't added that yet, and he's relatively stable at the moment. Usually, I restart the computer or the compiler

@veyaa
Copy link

veyaa commented Dec 26, 2023

Hello Craig, after the latest commit on Dec 22, I am not seeing this error anymore.
Thanks,

@veyaa
Copy link

veyaa commented Dec 27, 2023

Hello Craig, unfortunately I called it too soon, it took longer than usual but I am still seeing the same error.

@craig-warren craig-warren reopened this Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants