williamhunter / topy

Topology Optimization using Python
Other
481 stars 130 forks source link

execution error #51

Open ninja7v opened 3 years ago

ninja7v commented 3 years ago

I installed ToPy successfully on Windows, but when I try to execute it with the example "python .\optimise.py .\beam_2d_reci_10_iters.tpd" I keep having the error : IOError: [Errno 2] No such file or directory: 'C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\data\Q4bar.K' I tried on 2 computers and I have the problem on both. Did I do anything wrong? Thanks for your help.

williamhunter commented 3 years ago

Hi,

What is in your folder "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\data\"?

ninja7v commented 3 years ago

Thanks for your fast answer, here is the inside of the folder: 04/06/2021 03:32 PM

. 04/06/2021 03:32 PM .. 04/06/2021 03:32 PM 4,734 H18B_K.py 04/06/2021 03:32 PM 4,634 H18B_K.pyc 04/06/2021 03:32 PM 4,695 H8bar_K.py 04/06/2021 03:32 PM 4,598 H8bar_K.pyc 04/06/2021 03:32 PM 2,457 H8T_K.py 04/06/2021 03:32 PM 2,722 H8T_K.pyc 04/06/2021 03:32 PM 3,890 H8_K.py 04/06/2021 03:32 PM 3,868 H8_K.pyc 04/06/2021 03:32 PM 974 matlcons.py 04/06/2021 03:32 PM 864 matlcons.pyc 04/06/2021 03:32 PM 2,676 Q4bar_K.py 04/06/2021 03:32 PM 2,805 Q4bar_K.pyc 04/06/2021 03:32 PM 1,941 Q4T_K.py 04/06/2021 03:32 PM 2,251 Q4T_K.pyc 04/06/2021 03:32 PM 2,228 Q4_K.py 04/06/2021 03:32 PM 2,434 Q4_K.pyc 04/06/2021 03:32 PM 2,496 Q5B_K.py 04/06/2021 03:32 PM 2,713 Q5B_K.pyc 04/06/2021 03:32 PM 1,122 recreate_all.py 04/06/2021 03:32 PM 1,432 recreate_all.pyc 04/06/2021 03:32 PM 1 init.py 04/06/2021 03:32 PM 199 init.pyc 22 File(s) 55,734 bytes 2 Dir(s) 117,667,880,960 bytes free


From: William Hunter @.> Sent: Tuesday, April 6, 2021 16:12 To: williamhunter/topy @.> Cc: Luc @.>; Author @.> Subject: Re: [williamhunter/topy] execution error (#51)

Hi,

What is in your folder "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\data"?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/williamhunter/topy/issues/51#issuecomment-814153835, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMNEGJHZ7GFIWXX6ATGUBF3THMJEVANCNFSM42O2ADAA.

williamhunter commented 3 years ago

You can see that you don't have the Q4bar.K file.

What version of Python are you using?

What version of Topy did you install?

ninja7v commented 3 years ago

I picked Topy-master and Topy-0.4.1 but I get the error on both. I am using Python 2.7.18 on a virtual environment with Conda.

williamhunter commented 3 years ago

Did you follow the instructions on this page? https://github.com/williamhunter/topy/releases/tag/0.4.1

On Tue, 6 Apr 2021 at 16:29, Luc @.***> wrote:

I picked Topy-master and Topy-0.4.1 but I get the error on both. I am using Python 2.7.18 on a virtual environment with Conda.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/williamhunter/topy/issues/51#issuecomment-814167463, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMS2UIOD2CRF7EH4P5NILDTHMLFVANCNFSM42O2ADAA .

ninja7v commented 3 years ago

Yes I did.

williamhunter commented 3 years ago

Hmmm. I haven't looked at this in a few years. Give me some time and I'll investigate

ninja7v commented 3 years ago

Sure. Thanks a lot for your commitment. Just in case, here is the full output after I submitted the command: It seems as though all or some of the element stiffness matrices do not exist. Creating them... This is usually only required once and may take a few minutes. SymPy is integrating: K for Q4bar... Created C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology.K (stiffness matrix). Traceback (most recent call last): File ".\optimise.py", line 8, in import topy File "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy__init__.py", line 8, in from .topology import File "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\topology.py", line 16, in from .parser import tpd_file2dict, config2dict File "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\parser.py", line 14, in from .elements import File "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\elements.py", line 48, in Q4bar = load(fname) File "C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\numpy\lib\npyio.py", line 422, in load fid = open(os_fspath(file), "rb") IOError: [Errno 2] No such file or directory: 'C:\Users\LPT14\Anaconda3\envs\py27\lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\data\Q4bar.K'

Bassarey commented 3 years ago

Hello, my problem

PS C:\users\admin\Documents\topy\scripts> python optimise.py inverter_3d_etaopt_gsf_dquad.tpd Traceback (most recent call last): File "optimise.py", line 8, in import topy File "C:\Python27\lib\site-packages\topy__init.py", line 8, in from .topology import * File "C:\Python27\lib\site-packages\topy\topology.py", line 14, in from pysparse import superlu, itsolvers, precon File "C:\Python27\lib\site-packages\pysparse\init__.py", line 6, in from numpy._import_tools import PackageLoader ImportError: No module named _import_tools

PS C:\users\admin\Documents\topy\scripts> pip list Package Version


backports.functools-lru-cache 1.6.4 cycler 0.10.0 kiwisolver 1.1.0 matplotlib 2.2.5 mpmath 1.2.1 numpy 1.16.6+mkl pip 19.2.3 pyparsing 2.4.7 pysparse 1.3 python-dateutil 2.8.1 pytz 2021.1 PyVTK 0.5.18 setuptools 44.1.1 six 1.16.0 sympy 1.5.1 ToPy 0.3.2

shushu-qin commented 3 years ago

In my case, the problem came from np.load in elements.py. I solved this problem by modifying the load function in elements.py file, which is change load(fname) to load(fname, allow_pickle=True). In this way, it can successfully load the stiffness file.

Liyaguan commented 2 years ago

allow_pickle=True

didn't work

7over4 commented 1 year ago

Found a way, basically you need the missing .K "stiffness matrix" files. For some reason they are not generated during setup.py installation. I got them generated and I'm hosting them on my site sasserisop.com/topyKFiles.zip There is 7 of them you will need. Place these files under C:\Users\YOURUSERNAME\anaconda3\envs\py27\Lib\site-packages\topology_optimization-0.4.0-py2.7.egg\topy\data There is one more thing I had to do before I got it to work and that is to allow_pickle=True like shushu-qin mentioned, to do this: under the same directory with the .K files, go back up one directory and you will find elements.py From there, edit it with your text editor and change every instance of load(fname) to load(fname, allow_pickle=True). Now to test, open a terminal under the py27 environment you created, (this is assuming you went through the installation steps in github.com/williamhunter/topy/releases/tag/0.4.1). Now cd to the optimise.py file, in my case, type: cd C:\Users\YOURUSERNAME\Desktop\topy-0.4.1\scripts Now type: python .\optimise.py ../examples/mbb_beam/beam_2d_reci_10_iters.tpd If everything above was done correctly this will generate 10 iterations for the given tpd file and spit out the results in the same directory optimise.py is in. Hooray! Now all we need is a new fixed release for the masses. I might add a pull request :)