{"id":50800977,"url":"https://github.com/williamhunter/topy","last_synced_at":"2026-06-30T02:00:32.048Z","repository":{"id":46705978,"uuid":"42301105","full_name":"williamhunter/topy","owner":"williamhunter","description":"Topology Optimization using Python","archived":false,"fork":false,"pushed_at":"2022-08-31T11:37:33.000Z","size":8938,"stargazers_count":458,"open_issues_count":11,"forks_count":127,"subscribers_count":34,"default_branch":"master","last_synced_at":"2024-06-11T20:38:50.080Z","etag":null,"topics":["optimization","python","topology","topology-optimization","topy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamhunter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-11T09:55:30.000Z","updated_at":"2024-06-03T12:01:23.000Z","dependencies_parsed_at":"2022-09-01T05:01:27.354Z","dependency_job_id":null,"html_url":"https://github.com/williamhunter/topy","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/williamhunter/topy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamhunter%2Ftopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamhunter%2Ftopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamhunter%2Ftopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamhunter%2Ftopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamhunter","download_url":"https://codeload.github.com/williamhunter/topy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamhunter%2Ftopy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34949234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["optimization","python","topology","topology-optimization","topy"],"created_at":"2026-06-12T19:33:52.165Z","updated_at":"2026-06-30T02:00:32.037Z","avatar_url":"https://github.com/williamhunter.png","language":"Python","funding_links":[],"categories":["Optimization"],"sub_categories":["Verified vs declared"],"readme":"![pytest](https://github.com/mlaradji/topy/workflows/pytest/badge.svg)\n\n# ToPy\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"./imgsrc/topy_logo3d.png\" width=\"400\"\u003e\n\u003c/div\u003e\n\nToPy is a lightweight topology optimization framework for Python that can solve\ncompliance (stiffness), mechanism synthesis and heat conduction problems in 2D and 3D.\nPlease refer to the [ToPy Wiki](https://github.com/williamhunter/topy/wiki) for further information.\n\n## Example of a ToPy result\nAn [example TPD file and solution/result](https://github.com/williamhunter/ToPy/wiki/Examples-of-ToPy-results)\n\n## Installation\n**NOTE**: I've added a 0.4.1 release, which is older then the master branch, but will get you up and running with Python 2 and\nPysparse if you're willing to use the Anaconda Python distribution\n\nOnce you've downloaded the dependencies (see the [INSTALL](https://github.com/williamhunter/topy/blob/master/INSTALL.md)\nfile) all you need to do is the following:\n\nDownload the latest **stable release** from here: https://github.com/williamhunter/topy/releases/latest\n\nThen do\n\n```bash\n$ cd topy/topy\n$ python setup.py install\n```\n\n\n### ToPy and Python 3\nToPy is fairly old. I started working on it in 2005 and finished it around 2009, so that implies that the stable release only \nworks with Python 2. You can however pull the latest \"unstable\" version, which should work with Python 3 (thanks to the\nefforts of other people).\n\n## Getting started\nThe main class of **ToPy** is 'Topology'. It defines the main constraints,\ngrid and parameters of optimization -- but you don't really have to bother\nyourself with this if you just want to get some results.\n\n### There are two ways of defining a problem\n1. **TPD file**: You define the problem with keywords\n(see [Help](https://github.com/williamhunter/topy/wiki/Help)) in a simple text file and solve via the command line. The text file must have the extension `.tpd`\n2. **Config dictionary**: This is similar to the TPD file approach, however,\nyou define the problem directly in a Python file; it's very useful if you want to\nexperiment and don't want to keep making changes to a text file.\nYou can later save the Config keywords to a TPD file.\n\n### TPD (**T**oPy **P**roblem **D**efinition) file\nThere is a minimal set of parameters which is required for successful definition of a ToPy problem:\n```\nPROB_TYPE  : comp\nPROB_NAME  : mbb_beam_minimal\nETA        : 0.5\nDOF_PN     : 2\nVOL_FRAC   : 0.5\nFILT_RAD   : 1.5\nP_FAC      : 3\nELEM_K     : Q4\nNUM_ELEM_X : 60\nNUM_ELEM_Y : 20\nNUM_ELEM_Z : 0\nNUM_ITER   : 10\nFXTR_NODE_X: 1|21\nFXTR_NODE_Y: 1281\nLOAD_NODE_Y: 1\nLOAD_VALU_Y: -1\n```\nYou can read more about successful problem definition [here](https://github.com/williamhunter/topy/tree/master/templates).\n\nWhen the TPD file is defined, then the rest is simple:\n\n```python\nfrom topy import Topology\n\ntopology = Topology()\ntopology.load_tpd_file('file.tpd')\n```\n\n### Config dictionary\nFirst you have to define a config dictionary (note the similarity with a TPD\nfile, especially the keywords):\n\n```Python\nconfig = {\n     'DOF_PN': 2,\n     'ELEM_K': 'Q4',\n     'ETA': '0.5',\n     'FILT_RAD': 1.5,\n     'FXTR_NODE_X': range(1, 22),\n     'FXTR_NODE_Y': 1281,\n     'LOAD_NODE_Y': 1,\n     'LOAD_VALU_Y': -1,\n     'NUM_ELEM_X': 60,\n     'NUM_ELEM_Y': 20,\n     'NUM_ELEM_Z': 0,\n     'NUM_ITER': 94,\n     'PROB_NAME': 'beam_2d_reci',\n     'PROB_TYPE': 'comp',\n     'P_FAC': 3.0,\n     'VOL_FRAC': 0.5\n}\n```\nThe requirements are the same as for the TPD file.\n\n```Python\ntopology = Topology(config=config)\n```\n### Optimization (solving the problem)\n\nYou can use the command line solution:\n\n```bash\n$ python topy/scripts/optimise.py \u003cfilename\u003e.tpd\n```\n\nOr you can use a Python script:\n\n```Python\nimport topy\n\nconfig = {...}\nt = topy.Topology(config)\nt.set_top_params()\ntopy.optimise(t)\n```\n\n### Visualization (seeing the result)\nModule `topy.visualization` allows one to save the output as a `.png` image for 2D problems or as a `.vtk` file for 3D.\nThe VTK files can be viewed with Mayavi or ParaView.\nYou can animate the PNG images with\nthe [convert](https://www.imagemagick.org/script/convert.php) tool.\n\n```bash\nconvert -delay 35 *.png anim.gif\n```\n\n\u003cdiv align=\"left\"\u003e\n\t\u003cimg src=\"./imgsrc/beam_2d_reci_gsf.gif\" width=40%\u003e\n\t\u003cimg src=\"./imgsrc/inverter_2d_eta03.gif\" width=30%\u003e\n\t\u003cimg src=\"./imgsrc/t-piece_2d_Q4_eta04_gsf.gif\" width=20%\u003e\n\u003c/div\u003e\n\n## Tutorials\n[Tutorials](https://github.com/williamhunter/topy/wiki/Tutorials)\n\n## How to cite ToPy\nIf you've used ToPy in your research work or find it useful in any way, please consider to cite:\n```\n@misc{Hunter2007william,\n  author = {Hunter, William and others},\n  title = {ToPy - Topology optimization with Python},\n  year = {2017},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/williamhunter/topy}},\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamhunter%2Ftopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamhunter%2Ftopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamhunter%2Ftopy/lists"}