GithubHelp home page GithubHelp logo

williamhunter / topy Goto Github PK

View Code? Open in Web Editor NEW
470.0 34.0 129.0 8.73 MB

Topology Optimization using Python

License: Other

Python 100.00%
topy topology-optimization python optimization topology

topy's Introduction

Hi there ๐Ÿ‘‹

  • Iโ€™m currently working on nothing meaningful (I have a day job as a mechanical engineer so don't really have spare time to code)
  • Iโ€™m currently learning Julia (on and off, as I get time)

topy's People

Contributors

adityabalu avatar ataber avatar caiocarrara avatar googlecodeexporter avatar isosnovik avatar jestuber avatar louyu2015 avatar mlaradji avatar williamhunter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

topy's Issues

Replace Pysparse with something else for Python 3

Hello,
In order to accelerate a project, I'm attempting to utilize topy with a custom build of pysparse that is built with superlu_dist. The problem is that the include files between superlu and superlu_dist seem to be fairly different. (ex: instead of sp_ddef.h, there is super_ddef.h). I've tried to replace a number of includes within several of the sparse implementations and managed to get some compilation to occur, but it remains a difficult problem. do you know of a simpler way of building the package?

Can't install totally the program : "cannot import name superlu"

Hello,

I just installed pip, matplotlib, simpy, numpy, python-dev, pysparse (and of course topy) and now, it tells me that superlu isn't there.

I'm pretty much new about programming, so it's probably a mistake from a non-used to script person. I'm just starting to make few steps here.

I run Ubuntu 15.10 on a 64 bits machine, I use the system python language (Python 2.7.10).

Command typed

$ python optimise.py beam_2d_reci.tpd

Results

Traceback (most recent call last):                                    
  File "optimise.py", line 16, in <module>
    import topy
  File "/usr/local/lib/python2.7/dist-packages/topy/__init__.py", line 8, in <module>
    from topology import *
  File "/usr/local/lib/python2.7/dist-packages/topy/topology.py", line 19, in <module>
    from pysparse import superlu, itsolvers, precon
ImportError: cannot import name superlu

Cannot import topology

Hi, I'm a beginner and I'm not too familiar with this kind of issues. I've followed the install instructions and when I run ToPy with one of the example files I keep on getting the following error:
File "/home/mpuig/topy-0.4.1-py-2/examples/cantilever/optimise.py", line 9, in
from topy import topology
ImportError: cannot import name 'topology' from 'topy'

Any help would be much appreciated!
Thanks!

Write test

As there are several examples, the tests could just check whether the results of the optimization of these examples are correct.

Major improvements (discussion)

Hey folks

I've been thinking for a while about possible things that can be done. However, there are some problems that have to be discussed.

First, I think that the project has to be moved to Python 3 since Python 2 faces end-of-life in 2020. You probably know that supporting legacy software is sometimes extremely painful.

Second, we need to discuss cross-platform features of the package. I'm a Linux user so, to be honest, I do not care about other systems. However, I know that certain researchers use Windows or MacOS and do not want to learn new stuff. So, something has to be done in this case.

Finally, we can add the package to the official repository to make its installation easier.

I would like to discuss this with you before starting anything new.

V.

execution error

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.

TYpe ERROR

When I optimize the tpd file, it keeps throwing error. ANy advice?

python scripts/optimise.py /mnt/study/mengjun/end-effector/passive-gripper/build/test1

================================================================================
ToPy problem definition (TPD) file successfully parsed.
TPD file name: /mnt/study/mengjun/end-effector/passive-gripper/build/test1 (v2007)

Domain discretisation (NUM_ELEM_X x NUM_ELEM_Y x NUM_ELEM_Z) = 60 x 77 x 66
Element type (ELEM_K) = H8
Filter radius (FILT_RAD) = 1.8
Number of iterations (NUM_ITER) = 50
Problem type (PROB_TYPE) = comp
Problem name (PROB_NAME) = test1
Damping factor (ETA) = 0.40
Passive elements (PASV_ELEM) specified
No active elements (ACTV_ELEM) specified

Iter | Obj. func. | Vol. | Change | P_FAC | Q_FAC | Ave ETA | S-V frac.

ToPy: Solution for FEA converged after 537 iterations.
Traceback (most recent call last):
File "scripts/optimise.py", line 20, in
optimise(argv[1])
File "scripts/optimise.py", line 16, in optimise
topy.optimise(t)
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/topy/optimisation.py", line 67, in optimise
_optimise(topology)
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/topy/optimisation.py", line 23, in _optimise
t.update_desvars_oc()
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/topy/topology.py", line 535, in update_desvars_oc
pasv = np.take(idx, self.pasv) # new indices
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 189, in take
return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 66, in _wrapfunc
return _wrapit(obj, method, *args, **kwds)
File "/home/niux/anaconda3/envs/topy/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 46, in _wrapit
result = getattr(asarray(obj), method)(*args, **kwds)
TypeError: Cannot cast array data from dtype('float64') to dtype('int64') according to the rule 'safe'

error when running the example problem

when trying to run the example file, I get the following error message:
raise ValueError("Cannot load file containing pickled data " ValueError: Cannot load file containing pickled data when allow_pickle=False
any idea how I can solve this?

IOError

I'm getting the following error running the MBB example on Windows. It looks like running optimise.py the first time to create the stiffness matrices doesn't work for me.

topy_error

unable to import topy in windows

Not really sure where I went wrong, but do you have any insight to this error. I am using windows 10

Python 2.7.15 | packaged by conda-forge | (default, May  8 2018, 14:46:56) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import topy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\xxxx\Anaconda3\envs\py27\lib\site-packages\topy\__init__.py", line 10, in <module>
    from .elements import *
  File "C:\Users\xxxx\Anaconda3\envs\py27\lib\site-packages\topy\elements.py", line 47, in <module>
    Q4bar = load(fname)
  File "C:\Users\xxxx\Anaconda3\envs\py27\lib\site-packages\numpy\lib\npyio.py", line 372, in load
    fid = open(file, "rb")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\xxxx\\Anaconda3\\envs\\py27\\lib\\site-packages\\topy\\data\\Q4bar.K'
>>>

also, per your comment about pysparse on windows, conda has a package that installs easily
https://anaconda.org/guyer/pysparse

Thanks. Looking forward to exploring topy

Depth/Thickness

Hello,

Can I generate a set of 40x40 pixel images of random topological structures and also set a label on it for "depth"/"thickness" in this library?

Thanks :)

Help Needed: Unable to Install pysparse Due to Missing Microsoft Visual C++ 9.0

Hello everyone,

I'm encountering an issue while trying to install the pysparse library due to my system lacking the Microsoft Visual C++ 9.0 compiler. I've attempted to find the relevant installation resources on the official website, but it seems that this particular version of the resource is no longer easily available. My environment is on Windows 10, using Python 2.7.18 within Anaconda.

Problem Overview
During my attempt to install pysparse, I received an error message indicating that my system is missing Microsoft Visual C++ 9.0. This has led to a failure in the installation process due to the absence of this compiler.

Expected Outcome
I'm looking for a download resource for Microsoft Visual C++ 9.0 or any alternative solution that would allow me to proceed with the installation of topy. If anyone has encountered a similar issue and found a solution, I would greatly appreciate it if you could share it with me.

Environment Information
Operating System: Windows 10
Python Version: 2.7.18 (Anaconda environment)

Evaluate whether CHOLMOD is faster than SuperLU

SuperLU is via Pysparse, CHOLMOD is via CVXOPT. Both are direct sparse solvers, from what I've read it seems as though CHOLMOD might be faster, since it is specifically for positive definite matrices that result from FEA problems. If it's only marginally faster (<10%), it won't be worth it since number of dependant 3rd party packages will remain the same.

Housekeeping

Quite a few files need to be checked for contact details, license details, etc.

Start fleshing out mesher.py

Start working on this, perhaps first thing is just to integrate it into ToPy. Have to think about how I want to go about it...

no output in terminal

Hello, I am using Ubuntu 14.04 and my Topy installation is working: I get the expected result images in the mbb_beam example, and don't get any errors.
But I don't get any output in the terminal (standard ubuntu shell terminal).

I saw in the wiki here that we should see the results in output.
I don't have any log file created either.

I don't know python language. I have Python 2.7.6 installed, but maybe I did not install all the dependencies very well. For example, pysparse was installed using an ubuntu package, and not installed from pip : sudo apt-get install python-sparse (from here)

Is ther anything to activate the output or is it an issue?

ImportError: cannot import name superlu

When I try python scripts/optimise.py examples/heat/heat_3d_etaopt_gsf_dquad.tdp I get this error:

Traceback (most recent call last):
  File "scripts/optimise.py", line 8, in <module>
    import topy
  File "/usr/local/lib/python2.7/dist-packages/topy/__init__.py", line 8, in <module>
    from .topology import *
  File "/usr/local/lib/python2.7/dist-packages/topy/topology.py", line 14, in <module>
    from pysparse import superlu, itsolvers, precon
ImportError: cannot import name superlu

I think it is cause i was not able to install pysparse, when i try sudo pip install pysparsei receive this error:

compile options: '-DLENFUNC_OK=1 -DSCIPY_MKL_H -DHAVE_CBLAS -Ipysparse/sparse/src -I/tmp/pip-install-UotukF/pysparse/pysparse/include -I/usr/local/include -I/usr/include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/tmp/pip-install-UotukF/pysparse/pysparse/include -I/usr/include/python2.7 -c'
    x86_64-linux-gnu-gcc: pysparse/sparse/src/spmatrixmodule.c
    pysparse/sparse/src/spmatrixmodule.c:4:22: fatal error: spmatrix.h: No such file or directory
    compilation terminated.
    pysparse/sparse/src/spmatrixmodule.c:4:22: fatal error: spmatrix.h: No such file or directory
    compilation terminated.
    error: Command "x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DLENFUNC_OK=1 -DSCIPY_MKL_H -DHAVE_CBLAS -Ipysparse/sparse/src -I/tmp/pip-install-UotukF/pysparse/pysparse/include -I/usr/local/include -I/usr/include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I/tmp/pip-install-UotukF/pysparse/pysparse/include -I/usr/include/python2.7 -c pysparse/sparse/src/spmatrixmodule.c -o build/temp.linux-x86_64-2.7/pysparse/sparse/src/spmatrixmodule.o -MMD -MF build/temp.linux-x86_64-2.7/pysparse/sparse/src/spmatrixmodule.o.d" failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-UotukF/pysparse/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-BwLxfU/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-UotukF/pysparse/

any suggestions? I already tried to build Atlas cause sudo apt-get install Atlas3-base-def gave me "Unable to locate package" but it still gave me the same error.

Does python2.7 really still work?

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
ERROR: Invalid requirement: 'NumPy+MKL'

my:
ubuntu20.04
python2.7

Replace pysparse with scipy?

The pysparse library seems not being maintained anymore, the one that are available cannot adapt the current version of numpy. maybe it is necessary to replace it by some other well-maintained sparse algebra library such as scipy?

Add Gmsh msh format to visualisation.py for 2D

So that one can view the element and node numbers in Gmsh. It help a lot in defining problems (TPD files). Usage will be something like
create_2d_mesh(nx, ny, **kwargs)
which will create a 2d mesh (specifically, a MSH file) that can be viewed in Gmsh, as well as a skeleton TPD file. One can then visually see the node numbers that you want to constrain or load in Gmsh, and edit the corresponding TPD file.

Outputting a mesh

Hi,

is there a way to obtain a GMSH file as output rather than a png file?

Thank you!
Marti

How to visualize the generated .vtk files?

I tried to open the generated .vtk files (iteration results) in GMSH but failed. The error message is:

Error: Unknown type of cell 11

Is it a common error? I also wrote a python script to render them as point cloud. It's OK, but I don't know how to render them as voxels and I also prefer a simpler way. How do you visualize the results usually?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.