spacether / pycalculix

Python 3 library to automate and build finite element analysis (FEA) models in Calculix. Meshing uses Calculix or GMSH.
http://justinablack.com/pycalculix/
Apache License 2.0
170 stars 56 forks source link

Problem running 'pycalculix-add-feaprograms' #31

Closed pp4 closed 6 years ago

pp4 commented 6 years ago

Hi Justin,

Following your suggestion (https://github.com/spacether/pycalculix/issues/15#issuecomment-358070671), I ran 'pycalculix-add-feaprograms' with administrator privileges and, unlike before, the directory c:\users\ppe\app data\local\continuum\anaconda2\envs\python3\Scripts\gmsh-git-Windows64 was successfully created and gmsh installed.

However, the process ended with the following output:

(python3) C:\Windows\system32>pycalculix-add-feaprograms Detected Windows 64 bit Installing gmsh Downloading gmsh from http://gmsh.info/bin/Windows/gmsh-git-Windows64.zip Unzipping gmsh Removing gmsh zipfile Installing gmsh to c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\S cripts\gmsh-git-Windows64 1 dir(s) moved. Installing calculix (ccx) https://sourceforge.net/projects/calculixforwin/files/03.2/CL32-win64bit.zip/download/support Downloading CL32-win64bit.zip from /support Traceback (most recent call last): File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\ppe\AppData\Local\Continuum\anaconda2\envs\python3\Scripts\pycalculix-add-feaprograms.exe__main__.py", line 9, in File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-pac kages\pycalculix\installer.py", line 31, in add windows_add(bitsize) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\pycalculix\installer.py", line 169, in windows_add win_add_ccx(bitsize, "https://sourceforge.net/projects/calculixforwin/files/03.2/", "ccx") File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\pycalculix\installer.py", line 288, in win_add_ccx response = requests.get(zipfile_url, stream=True, headers=headers) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\api.py", line 72, in get return request('get', url, params=params, kwargs) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\api.py", line 58, in request return session.request(method=method, url=url, kwargs) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\sessions.py", line 494, in request prep = self.prepare_request(req) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\sessions.py", line 437, in prepare_request hooks=merge_hooks(request.hooks, self.hooks), File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\models.py", line 305, in prepare self.prepare_url(url, params) File "c:\users\ppe\appdata\local\continuum\anaconda2\envs\python3\lib\site-packages\requests\models.py", line 379, in prepare_url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '/support': No schema supplied. Perhaps you meant http:///support? (python3) C:\Windows\system32>

Is it trying to download CL32-win64bit.zip from https://sourceforge.net/projects/calculixforwin/files/03.2/CL32-win64bit.zip/download/support (wrong link), instead of from https://sourceforge.net/projects/calculixforwin/files/03.2/CL32-win64bit.zip/download (correct link) ?

I afterwards tried running the example "hole-in-plate-full.py" and execution stopped when trying to write the 'hole-in-plate-full.frd' file (before being able to successfully install gmsh, it stopped when trying to write the 'hole-in-plate-full.inp' file).

File: hole-in-plate-full.inp was written ccx hole-in-plate-full Solving done! ERROR: results .frd file was not written! Traceback (most recent call last): File "", line 1, in runfile('D:/hole-in-plate-full.py', wdir='D:') File "C:\Users\ppe\AppData\Local\Continuum\Anaconda2\envs\python3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "C:\Users\ppe\AppData\Local\Continuum\Anaconda2\envs\python3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "D:/hole-in-plate-full.py", line 53, in sx = prob.rfile.get_nmax('Sx') File "C:\Users\ppe\AppData\Local\Continuum\Anaconda2\envs\python3\lib\site-packages\pycalculix\results_file.py", line 698, in get_nmax data_dict = self.__get_data_dict(time, 'node') File "C:\Users\ppe\AppData\Local\Continuum\Anaconda2\envs\python3\lib\site-packages\pycalculix\results_file.py", line 671, in get_data_dict res = self.results[self.__time][type_str] KeyError: -1

Therefore, I am apparently facing issue #15, even though I've update to pycalculix 0.9.4 as you suggested (https://github.com/spacether/pycalculix/issues/15#issuecomment-349199095

Many thanks for your help, Justin! All the best, Pedro

pp4 commented 6 years ago

The problem is that a wrong URL to download CL32-win64bit.zip is being generated by the function get_direct_url( ), when called inside the function win_add_ccx( ).

I assigned the direct link [1] to the variable zipfile_url (in the file installer.py), instead of letting it be assigned by the function get_direct_url( ), and then installer is able to run properly and install CalculiXforWin.

[1] https://downloads.sourceforge.net/project/calculixforwin/03.2/CL32-win64bit.zip?r=&ts=1523363869&use_mirror=netcologne

spacether commented 6 years ago

@pp4 can you send me a PR or include a snippet of what to change the code from and to to fix it?

pp4 commented 6 years ago

I simply hardcoded the download URL in the function win_add_ccx( ):

    zipfile_name = zipfile_webpage_url.split('/')[-2]
    print(zipfile_webpage_url)
#    zipfile_url = get_direct_url(zipfile_webpage_url, headers)
    zipfile_url = 'https://downloads.sourceforge.net/project/calculixforwin/03.2/CL32-win64bit.zip?r=&ts=1523363869&use_mirror=netcologne'
    print(zipfile_url)

And I'm running Python 3.6.5 in Anaconda 5.1.0 64-bit, in Windows 7 64-bit.

spacether commented 6 years ago

Your output above shows that the function get_direct_url is no longer working. The hosting site has probably changed how it is formatting its webpage. When I release v 0.9.5 I will include a fix for this issue. I'm currently working on the 0.9.5 update.

spacether commented 6 years ago

The installer can now install calculix and gmsh on Windows 64 bit per this commit: https://github.com/spacether/pycalculix/commit/6a14b299737f2dd283c458bd6026ca7e886c0eee Sadly, the latest version of gmsh hangs when meshing our sample files. My next todo list item is to peg the installed gmsh versions to working versions on Windows, Mac, and Linux.

spacether commented 6 years ago

I will close this issue once I merge my above commit into master.

spacether commented 6 years ago

The version of gmsh installed on windows is now pegged to 3.0.5 which works correctly.

spacether commented 6 years ago

Mac OS X gmsh is pegged to 3.0.5 which works correctly

spacether commented 6 years ago

This issue is fixed in v0.9.5 which is now released on Github

pp4 commented 6 years ago

Many thanks, Justin!