pygran icon indicating copy to clipboard operation
pygran copied to clipboard

ValueError: Could not convert string to float #help #value_error

Open jauharr opened this issue 1 year ago • 54 comments

Hi I am working with Pygran in WSL. Initially I faced the error of latex could not be found. I installed latex then I was able to perform visco elastic and elastoplastic models. When I try to run an actual dem such as multi-sphere case or another from PyGran examples, I face value error. Please help how this can be resolved.
image

jauharr avatar Sep 26 '22 07:09 jauharr

Which version pf pygran are you using and how did you install it?

anabiman avatar Sep 26 '22 16:09 anabiman

I installed it in WSL Ubuntu with pip3 install pygran, The version information is attached in the figure. image

jauharr avatar Sep 27 '22 03:09 jauharr

Please use version 1.4.0 instead (just released). I'm in the process of updating the online doc and examples/scripts as well. I will keep this issue open for a bit in case you encounter any new issues/problems.

pip install pygran[extra]

should install pygran and all its extra dependencies. For running specific scripts with plotting/interactive visualization, you might need to install additional requirements like matplotlib, etc.

anabiman avatar Sep 28 '22 08:09 anabiman

I did run the mentioned command but I was unable to install the version 1.4.0, the installed version continued to be 1.3.1. I have matplotlib installed. The image shows after I run the command image Please guide me if I am doing anything wrong or version 1.4 is not available on pip. Moreover, the value error persists.

jauharr avatar Sep 28 '22 18:09 jauharr

Try removing v1.3.1 and making a fresh installation:

 pip uninstall pygran -y
 pip install pygran[extra]

To confirm you have the right version, run: python -c "import pygran; print('pygran version = ', pygran.__version__)" You should see v1.4.0 printed.

anabiman avatar Sep 28 '22 18:09 anabiman

hi the version is up to date, but error persists image

jauharr avatar Sep 29 '22 02:09 jauharr

I can run the multisphere / rotating tumbler just fine. Where are you getting your material definitions from? Or how are you defining them? In the original script, from pygran.params import organic is how it's done. Post here your full script so I can try to reproduce the error.

anabiman avatar Sep 29 '22 03:09 anabiman

from pygran import simulation
from pygran.params import organic

# Create a dictionary of physical parameters
params = {

    # Define the system
    'boundary': ('f','f','f'), # fixed BCs
    'box':  (-1, 1, -1 , 1, -1, 1), # simulation box size

    # Define component(s)
    'species': ({'material': organic, 'style': 'multisphere/tablet', 'radius': 2e-2, 'nspheres': 12, 'length': 1e-1},
          ),

    # Set skin distance to be 1/4 particle diameter
    'nns_skin': 5e-3,

    # Timestep
    'dt': 2e-7,
 
    # Apply gravitional force in the negative direction along the z-axis
    'gravity': (9.81, 0, 0, -1),

    # Setup I/O
    'traj': {'pfile': 'particles*.vtk', 'mfile': 'tumbler*.vtk'},
    
    # Stage runs [optional]
    'stages': {'insertion': 1e6, 'rotation': 1e6},

    # Define mesh for rotating mesh (tumbler)
    'mesh': {
              'tumbler': {'file': 'mesh/tumbler.stl', 'mtype': 'mesh/surface/stress', 'material': organic, \
                          'args': {'scale': 1e-3}},
	}
  }
# Create an instance of the DEM class
sim = simulation.DEM(**params)

# Insert 800 particles once in a cylinder
insert = sim.insert(species=1, value=800, region=('cylinder', 'y', 0, 0, 0.7, -0.4, 0.4), \
                    args={'orientation': 'random'})

# Add dissipative force proprtional to tablet velocity
air_resistance = sim.addViscous(species=1, gamma=0.1)

# Run insertion stage
sim.run(params['stages']['insertion'], params['dt'])

# Delete insertion fix
sim.remove(insert)

# Rotate mesh (tumbler) along the xoz plane
sim.moveMesh(name='tumbler', rotate=('origin', 0, 0, 0), axis=(0, 1, 0), period=5e-1)

# Run rotation stage
sim.run(params['stages']['rotation'], params['dt'])

jauharr avatar Sep 30 '22 03:09 jauharr

The script you posted runs just fine on my system.

anabiman avatar Oct 01 '22 05:10 anabiman

Th is what I get when I import organic from pygran.params:

>>> from pygran.params import organic
>>> organic
{
    'youngsModulus': 10000000.0, 
    'poissonsRatio': 0.25, 
    'coefficientFriction': 0.5, 
    'coefficientRollingFriction': 0.0, 
    'cohesionEnergyDensity': 0.0, 
    'coefficientRestitution': 0.9, 
    'coefficientRollingViscousDamping': 0.1, 
    'yieldPress': 2200000.0, 
    'characteristicVelocity': 0.1, 
    'density': 1000.0
}

anabiman avatar Oct 01 '22 05:10 anabiman

The organic output in may case is same. image The error comes when I run it in Jupyter notebook (VS Code) I am running this script in Jupyter notebook in WSL2 Ubuntu under Windows 11. Would you please guide with respect to development environment checks?

jauharr avatar Oct 03 '22 16:10 jauharr

Have you tried running the script directly from the WSL2 terminal i.e. without Jupyter notebook or VS Code ?

anabiman avatar Oct 03 '22 18:10 anabiman

I have modified script to run it directly Ubuntu terminal. The script is as follows:

from pygran import simulation
from pygran.params import organic
print("<<< Import Complete >>>")
# Create a dictionary of physical parameters
params = {

    # Define the system
    'boundary': ('f','f','f'), # fixed BCs
    'box':  (-1, 1, -1 , 1, -1, 1), # simulation box size

    # Define component(s)
    'species': ({'material': organic, 'style': 'multisphere/tablet', 'radius': 2e-2, 'nspheres': 12, 'length': 1e-1},
          ),

    # Set skin distance to be 1/4 particle diameter
    'nns_skin': 5e-3,

    # Timestep
    'dt': 2e-7,
 
    # Apply gravitional force in the negative direction along the z-axis
    'gravity': (9.81, 0, 0, -1),

    # Setup I/O
    'traj': {'pfile': 'particles*.vtk', 'mfile': 'tumbler*.vtk'},
    
    # Stage runs [optional]
    'stages': {'insertion': 1e6, 'rotation': 1e6},

    # Define mesh for rotating mesh (tumbler)
    'mesh': {
              'tumbler': {'file': 'mesh/tumbler.stl', 'mtype': 'mesh/surface/stress', 'material': organic, \
                          'args': {'scale': 1e-3}},
	}
  }
print("<<< Params loaded >>>")
  # Create an instance of the DEM class
sim = simulation.DEM(**params)
print("<<< RUN DEM Simulation >>>")
# Insert 800 particles once in a cylinder
insert = sim.insert(species=1, value=80, region=('cylinder', 'y', 0, 0, 0.7, -0.4, 0.4), \
                    args={'orientation': 'random'})
print("<<< Particles inserted >>>")
# Add dissipative force proprtional to tablet velocity
air_resistance = sim.addViscous(species=1, gamma=0.1)
print("<<< Air resistance added >>>")
# Run insertion stage
sim.run(params['stages']['insertion'], params['dt'])
print("The initial run started")
# Delete insertion fix
sim.remove(insert)
print("<<< The insert removed >>>")
# Rotate mesh (tumbler) along the xoz plane
sim.moveMesh(name='tumbler', rotate=('origin', 0, 0, 0), axis=(0, 1, 0), period=5e-1)
print("<<< Mesh Moved >>>")
# Run rotation stage
sim.run(params['stages']['rotation'], params['dt'])

However the output or run is stuck at the sim = simulation.DEM(**params)

The output is shown here:

<<< Import Complete >>>
<<< Params loaded >>>

jauharr avatar Oct 03 '22 18:10 jauharr

The stalling is due to pygran trying to find the DEM engine (default is liggghts) library. My bet is you don't have it installed on your system.

anabiman avatar Oct 04 '22 04:10 anabiman

Try the following:

git clone https://github.com/anabiman/pyliggghts
cd pyliggghts
python setup.py build

This will attempt to compile libliggghts.so on your machine, which will be picked up the next time you run pygran. You need to make sure you have an mpi compiler and VTK 9.1 installed on your machine.

P.S. The old LIGGGHTS code (3.8.0) from CFDEM is no longer supported and cannot be compiled with the latest versions of gcc.

anabiman avatar Oct 04 '22 04:10 anabiman

I have the old liggghts from CFDEM, i will work on the solution proposed by you.

jauharr avatar Oct 04 '22 04:10 jauharr

If u already have libliggghts.so installed on your machine, then no need to compile anything. pygran should be able to find it. You can also tell pygran where to find the liggghts library file with pygran.simulation.tools.configure(path: str, version: str, src: str).

anabiman avatar Oct 04 '22 05:10 anabiman

Would you please share details or step wise instructions. I have libliggghts.so.3 and libliggghts.so.3.8.0 .
I have tried to compile but there is problem of make mpi non-zero exit status 2. I have installed VTK 9.1 but I kept on receiving the fatal error: vtkSmartPointer.h : No such file or directory

jauharr avatar Oct 04 '22 06:10 jauharr

You're missing the header files. These are packaged on Ubuntu with the libvtk{version}-dev, so probably something like this should work:

sudo apt install libvtk9.1-dev

anabiman avatar Oct 04 '22 17:10 anabiman

I run the command but fell into error. image I tried to manually copy the vtk files but I was unable to paste them in opt folder. I followed this link. https://medium.com/@lyl1617670866/how-to-install-vtk-9-1-on-ubuntu-18-04-a4530ce790da

jauharr avatar Oct 04 '22 19:10 jauharr

I dont know what it's exactly called (I'm not on Ubuntu), I was just showing an example. Search for it with apt-cache search libvtk. You should find the -dev version and install it.

anabiman avatar Oct 04 '22 20:10 anabiman

According to launchpad, the header files are stored in the the pkg libvtk9-dev.

anabiman avatar Oct 04 '22 20:10 anabiman

Can pyliggghts be compiled on native windows? Without WSL Ubuntu?

jauharr avatar Oct 05 '22 06:10 jauharr

It can but hard to do and would require a lot of changes to the make files.

anabiman avatar Oct 05 '22 07:10 anabiman

I am working to resolve the issue, but I am unable to find solution for vtk problem.

jauharr avatar Oct 05 '22 07:10 jauharr

Were you able to install libvtk9-dev?

anabiman avatar Oct 05 '22 19:10 anabiman

I am extracting files for vtk9.1 at the moment, then I will attempt to install it.

jauharr avatar Oct 05 '22 19:10 jauharr

If you're on ubuntu, it should be available via aptitude i.e. no need to manually install the header files.

anabiman avatar Oct 05 '22 19:10 anabiman

I am on the WSL2 Ubuntu. I have tried the official link but in vain. The link is here Please guide me with your experience.

jauharr avatar Oct 05 '22 19:10 jauharr

I already asked you to search for the library via aptitude: apt-cache search libvtk and find its name. What did you get?

anabiman avatar Oct 05 '22 21:10 anabiman