Skip to content

Commit

Permalink
Partially implemented simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
Chelsea486MHz committed Jan 9, 2024
1 parent bdbc62b commit 933d292
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![](./docs/logo.png)

**Status (master branch)**
**Status (main branch)**

![](https://img.shields.io/badge/maintained-yes-green) ![](https://img.shields.io/badge/license-MIT-blue) ![](https://img.shields.io/github/actions/workflow/status/Chelsea486MHz/stargazer/auth.yml?label=build%20(auth)) ![](https://img.shields.io/github/actions/workflow/status/Chelsea486MHz/stargazer/manager.yml?label=build%20(manager)) ![](https://img.shields.io/github/actions/workflow/status/Chelsea486MHz/stargazer/compute.yml?label=build%20(compute))

Expand Down
36 changes: 36 additions & 0 deletions manager/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,43 @@ def api_manager_simulate():
if duration <= 0:
return jsonify({'success': False}), 400

# Log the number of bodies
print('{} bodies to simulate'.format(len(bodies)))

# Simulate the universe
for i in range(int(duration / timestep)):
# Log the current iteration
print('Iteration {}/{}'.format(i, int(duration / timestep)))

# Log the number of compute nodes
print('{} compute nodes available'.format(len(registered)))

# Configure the compute nodes
for node in registered:
requests.post('{}/api/compute/configure'.format(node[1]),
json={'constants': {'timestep': timestep,
'gravity': gravity,
'electrostatic': electrostatic},
'bodies': bodies},
timeout=5)
print('Configured compute node {}'.format(node[1]))

# Send the updated bodies to the compute nodes
for node in registered:
requests.post('{}/api/compute/bodies'.format(node[1]),
json={'body': bodies},
timeout=5)
print('Refreshed bodies on compute node {}'.format(node[1]))

# Assign a range of bodies to each registered compute node
for node in registered:
start = int(len(bodies) / len(registered) * registered.index(node))
end = int(len(bodies) / len(registered) * (registered.index(node) + 1))
requests.post('{}/api/compute/assign'.format(node[1]),
json={'start': start,
'end': end},
timeout=5)
print('Assigned bodies {}-{} to compute node {}'.format(start, end, node[1]))

return jsonify({'success': True}), 200

Expand Down

0 comments on commit 933d292

Please sign in to comment.