{"id":13651574,"url":"https://github.com/johngrantuk/golem-array","last_synced_at":"2025-10-25T17:31:41.928Z","repository":{"id":91116125,"uuid":"323645610","full_name":"johngrantuk/golem-array","owner":"johngrantuk","description":"Winner of the Golem Gitcoin Hackathon 2020 (https://blog.golemproject.net/meet-the-winners-golem-gitcoin-hackathon-2020/). This app lets people design, simulate, and analyse antenna arrays without the need to utilize commercial and expensive applications.","archived":false,"fork":false,"pushed_at":"2020-12-29T16:10:21.000Z","size":40882,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-14T01:54:22.973Z","etag":null,"topics":["golem"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johngrantuk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-22T14:15:41.000Z","updated_at":"2024-03-03T06:38:51.000Z","dependencies_parsed_at":"2024-01-03T05:15:43.008Z","dependency_job_id":"9aebf36a-e171-4309-8cce-57b441ad8ca3","html_url":"https://github.com/johngrantuk/golem-array","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johngrantuk%2Fgolem-array","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johngrantuk%2Fgolem-array/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johngrantuk%2Fgolem-array/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johngrantuk%2Fgolem-array/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johngrantuk","download_url":"https://codeload.github.com/johngrantuk/golem-array/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865216,"owners_count":16555929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["golem"],"created_at":"2024-08-02T02:00:50.614Z","updated_at":"2025-10-25T17:31:40.746Z","avatar_url":"https://github.com/johngrantuk.png","language":"Python","readme":"## Antenna Array Design \u0026 Simulation - Powered By Golem\n\n[Demo Video](https://youtu.be/wa4zohSWmtA)\n\nWelcome to my Gitcoin Golem Hackathon entry. Traditional antenna design/analysis usually relies on very expensive commercial tooling which requires powerful and costly hardware for processing. This creates a high barrier of entry and even when that can be overcome collaboration is difficult due to proprietary file types and seat licensing. This project aims to overcome these issues.\n\nUsing Golem to overcome the hardware barrier - [Golem Network](https://golem.network/) is a cloud computing power service where everyone can develop, manage and execute workloads in an unstoppable, inexpensive and censorship-free environment. The project makes use of this by essentially breaking down large problems (i.e. many antenna elements) into single problems (i.e. a single element) that can be run on individual Golem workers. Now anyone can run a large and complex analysis without access to a very expensive, dedicated machine.\n\nThe application aims to create a foundational setup that makes it easily extensible without the user requiring knowledge of the Golem system. This make it easy for users to 'drop in' their own element types and run analysis on them. Focus can be on the antenna design rather than the Golem interaction.\n\nCollaboration and knowledge sharing can assist in learning and lead to innovation. Using the extension option anyone can contribute to build a collection of different element types that anyone can run and adapt. This could be developed further to include functionality to add different output types - i.e. more plots, tables, etc and even new solving methods, i.e. 3D Finite Element for microwave structures. A community of passionate contributors and enthusiasts leads to more innovation and can grow an applications development further than an individual can.\n\n### The Application\n\nThis application is a Command Line tool that allows a user to simulate antenna patterns for an X by Y element array. For a proper introduction to Antenna Arrays and explanation of the Python code please see my series [here](https://johngrant.medium.com/antenna-arrays-and-python-introduction-8e3b612ecdfb).\n\nEach elements field is processed by a Golem worker. By default a 2x1 rectangular element array is analysed but the configuration can be changed (along with freq, patch size, etc) using various inputs - see instructions below.\n\nAs explained above the goal was to make this a foundational setup so that others can easily extend it. To demonstrate this functionality there is also an example drop in of a Horn element that can be analysed instead of the patch. More details can be found below.\n\n![Patch Array](Screenshot-Output.png)\n\n## How To Run Locally\n\nIn a fresh dir create a Python environment. (I use [Virtualenv](https://virtualenv.pypa.io/en/stable/)):\n\n`$ pyenv virtualenv 3.7.0 golem-array`\n\n`$ pyenv activate golem-array`\n\nClone this repo:\n\n`$ git clone https://github.com/johngrantuk/golem-array.git`\n\n`$ cd golem-array`\n\nInstall local packages:\n\n`$ pip install -r requirements.txt`\n\nIn a new tab run the yagna daemon locally (for instructions on how to set this up see [here](https://handbook.golem.network/requestor-tutorials/flash-tutorial-of-requestor-development#running-the-yagna-daemon)):\n\n`$ yagna service run`\n\nIn another tab init yagna with funds, etc:\n\n`$ yagna payment init -r --driver=ngnt`\n\nAnd create and save your app key:\n\n`$ yagna app-key create requestor`\n\nNow in your app dir export your key:\n\n`$ export YAGNA_APPKEY=insert-your-32-char-app-key-here`\n\nAnd finally you can run the array simulator:\n\n`$ python requestor.py`\n\nThis will run the default simulation which is for a two element array where the elements are rectangular patches. If all runs successfully the output will show plots of the array pattern. It is possible to change number of elements, freq, patch width/length, to see the list of options run: `$ python requestor.py -h`\n\n### Extending To Other Element Types\n\nOne of the main goals of this project is to create a foundational setup that makes this solver easily extensible without the user requiring knowledge of the Golem system. This allows anyone to drop in their own antenna element types (or in the future plotting outputs and solver types) and run analysis (powered by Golem) on almost any machine.\n\nAn element 'type' must have a matching folder in root dir, for example the default type is 'Patch'. This folder should include all required scripts for analysing that specific element type along with a runAnalysis.py script. The runAnalysis.py is a common script that will be run by each worker. The script should run the analysis for that specific element (using files from element folder) and save the result in an elementresult.csv. The Horn directory demonstrates an example - replacing the patch element with a Horn element (represented by a cos q(theta) function). This example can be run using: `$ python requestor.py --type Horn`.\n\n### Golem Tips \u0026 Help\n\nSome tips I found helpful:\n\nGolem [Discord](https://discord.com/invite/y29dtcM) is very supportive if I had issues (thanks Philip from Golem for lots of initial support).\n\nClearing yagna - Sometimes yagna would become stuck or behave funny. I found clearing it out and starting from fresh helped. Run `$ rm -rf $HOME/Library/Application\\ Support/GolemFactory.yagna` then do run, init, key again.\n\nRunning with the older version to init yagna seemed more stable to me: `$ yagna payment init -r --driver=ngnt`\n\nI found having a very basic requestor file that could be run as a check against an image helped to make sure things were running correctly. If it failed then something was wrong elsewhere (i.e. Docker image, funny yagna, etc). Maybe this will help someone:\n\n```\nimport asyncio\nfrom yapapi import Executor, Task, WorkContext\nfrom yapapi.log import enable_default_logger, log_summary, log_event_repr\nfrom yapapi.package import vm\nfrom datetime import timedelta\n\nasync def main(subnet_tag: str):\n    package = await vm.repo(\n        image_hash=\"b6aefad11aa7248577536efb8f453a12b7d060e1e56a08aa76886a3e\",\n        min_mem_gib=0.5,\n        min_storage_gib=2.0,\n    )\n\n    async def worker(ctx: WorkContext, tasks):\n        print(\"WORKER\")\n        async for task in tasks:\n            ctx.run(\"/bin/sh\", \"-c\", f\"ls -l \u003e\u003e /golem/work/output.txt\")\n            ctx.download_file(\"/golem/work/output.txt\", \"output.txt\")\n            # To test python scripts run something like below is useful where mainTest.py is a VERY simple script\n            # ctx.send_file(\"main.py\", \"/golem/work/mainTest.py\")\n            # ctx.run(\"/bin/sh\", \"-c\", f\"python3 /golem/work/main.py \u003e\u003e /golem/work/output.txt\")\n            yield ctx.commit()\n            task.accept_result()\n\n    async with Executor(\n        package=package,\n        max_workers=3,\n        budget=10.0,\n        timeout=timedelta(minutes=10),\n        subnet_tag=subnet_tag,\n        event_consumer=log_summary(),\n    ) as executor:\n        print('Executor')\n\n        async for _task in executor.submit(worker, [Task(data=None)]):\n            print('EXECUTOR DONE')\n\nenable_default_logger()\nloop = asyncio.get_event_loop()\ntask = loop.create_task(main(subnet_tag=\"community.3\"))\ntry:\n    asyncio.get_event_loop().run_until_complete(task)\nexcept (Exception, KeyboardInterrupt) as e:\n    print(e)\n    task.cancel()\n    asyncio.get_event_loop().run_until_complete(task)\n```\n\n#### Custom Docker\n\nThis project uses a (very basic) custom Dockerfile - see Dockerfile. I had to experiment a bit to get it right and these were handy steps to keep at hand:\n\nDocs: https://handbook.golem.network/requestor-tutorials/convert-a-docker-image-into-a-golem-image\n\nInstall gvmkit-build (only needs to be done once):\n\n`$ pip install gvmkit-build`\n\nCreate your own docker file and save, i.e. Dockerfile.\n\nBuild image: `$ docker build -t docker-example .`\n\nBuild and push Golem Image (remember to make note of hash):\n\n`$ gvmkit-build docker-example`\n\n`$ gvmkit-build docker-example --push`\n\nSometime useful to see your images:\n\n`$ docker images`\n\n## To Dos\n\nCreate a user interface - this was a bit of stretch for me this time round thanks to 🎅🎄! In an ideal world a web application could open this up even further by making it easier to run.\n\nLibrary of community element types, plotting methods and solver methods - currently anyone could create pull request to add a new element type to the Github repo. I would like it to be as easy to update the plotting options and eventually solver methods too.  \n","funding_links":[],"categories":["Apps","Archive"],"sub_categories":["Data Simulation","Apps"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohngrantuk%2Fgolem-array","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohngrantuk%2Fgolem-array","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohngrantuk%2Fgolem-array/lists"}