# FissionMunk
![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)
![License](https://img.shields.io/badge/license-MIT-green)
![PyPI version](https://badge.fury.io/py/fissionmunk.svg)
[![API Reference](https://img.shields.io/badge/API%20Reference-Docs-blue)](https://ianiket23.github.io/FissionMunk/)
**FissionMunk** is a lightweight 2D physics open source python library designed to simulate nuclear fission reactor mechanics. It enables users to visualize interactions between neutrons and uranium atoms, providing valuable insights into fission dynamics with customizable parameters, such as neutron occurrence probabilities, moderators, and control rods. FissionMunk is ideal for educational simulations, nuclear physics research, and interactive demos, and is built on top of the [Pymunk](http://www.pymunk.org/) library.
2024, Aniket Mishra - [ianiket23@github.io](https://ianiket23.github.io/)
- **Documentation**: [https://ianiket23.github.io/FissionMunk/](https://ianiket23.github.io/FissionMunk/)
- **Source code**: [https://github.com/iAniket23/fissionmunk](https://github.com/iAniket23/fissionmunk)
- **PyPI**: [https://pypi.org/project/fissionmunk/](https://pypi.org/project/fissionmunk/)
- **Bug reports**: [https://github.com/iAniket23/fissionmunk/issues](https://github.com/iAniket23/fissionmunk/issues)
## Features
- Interactive Simulation: Visualize neutron interactions with uranium in real-time, with configurable parameters.
- Modularity: Use customizable modules to add moderators, control rods, and other reactor elements.
- Educational Tool: Ideal for students and educators to explore nuclear fission mechanics.
- Open-Source: Fully open-source and extensible for customization and additional functionality.
## Getting Started with FissionMunk
FissionMunk makes it easy to simulate and visualize nuclear fission dynamics.
![rbmk](media/media_rbmk.gif)
To get started, follow these steps:
### Installation
To install FissionMunk, use `pip`:
```bash
pip install fissionmunk
```
### Set Up Your First Simulation
Now that you’ve installed FissionMunk, let's create a very basic simulation. First let's install a visualization library such as pygame (`pip install pygame`).
Here's an example to help you get started:
#### Example: Basic Fission Simulation
Now let's start by importing these libraries
```python
import pygame
from fissionmunk import Core
from fissionmunk import Moderator
from fissionmunk import ControlRod
from fissionmunk import Fuel
from fissionmunk import Water
from fissionmunk import Material
from fissionmunk import Mechanics
```
Initialize a display canvas using pygame
```python
# Initialize Pygame
pygame.init()
display = pygame.display.set_mode((700, 600))
clock = pygame.time.Clock()
FPS = 60
```
Now moving onto some fun stuff with Fissionmunk. In order to do simulation with fissionmunk we need to have some key items.
- **Core**: Manages the main simulation environment and fuel elements.
- **ControlRod**: Controls neutron absorption, allowing for fission rate adjustments.
- **Moderator**: Slows down neutrons to maintain optimal reaction rates.
- **FuelElement**: Represents fuel elements, such as uranium atoms, in the simulation.
- **Neutron**: Models individual neutrons and their interactions.
One thing to keep in mind is that we can tweak the probability of the occurance of the Fuel elements in a fuel rod.
Uranium-235 doesn't just occur all of a sudden in a rod but for the sake of the simulation we can pretend that Uranium-235 randomly occurs (refuel) in the rod.
```python
# Create a core object
core = Core(length=700, width=600,thermal_factor=4, cold_factor=1, fast_factor=10)
moderator = Moderator(length=10, width=580, position=(600, 290), material=Material.GRAPHITE)
control_rod = ControlRod(length=10, width=600, position=(500, 0), tag="E", movement_range=[20, 580],material=Material.BORON_CARBIDE)
fuel_rod = Fuel(fuel_element_gap=10,uranium_occurance_probability=0.0001, xenon_occurance_probability=0.00001, xenon_decay_probability=0.00001, element_radius=10, width=560, position=(300, 25))
```
We have initialized these reactor objects, and now it's time to actually add these in our Core.
```python
core.add_moderator_to_core(moderator)
core.add_control_rod_to_core(control_rod)
core.add_fuel_rod_to_core(fuel_rod)
```
Now let's add some water in our core. Water has some unique properties in the reactor. It acts as a neutron poison, as in, it absorbs neutron. One more property water have is temperature. More fission equals more heat which results in making the water heat up (ultimately resulting in water evaporating).
Now let's rather than making a big water rod, for the sake of our sample example, let's make a grid of water squares.
```python
for j in range(25, 580, 30):
water = Water(length=25, width=25, position=(450, j), coolant=True, hard_limit=30, temperature_threshold=100, material=Material.WATER)
core.add_water_to_core(water)
```
Now in order to handle all the collisions and properties (like regulating water temperature and random neutron generation). We need have
Mechanic object attached to our Core
```python
mechanics = Mechanics(core)
```
Now it's time to go to our pygame loop and draw objects.
```python
def game():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
display.fill((255, 255, 255))
```
Now let's grab the water in our core and draw it. We draw the water only if it is not removed (evaporated) cause of high temperature.
```python
for water in core.get_water_list():
pos = water.get_body().position
pos = int(pos.x), int(pos.y)
if water.removed:
pygame.draw.rect(display, (255, 255, 255), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))
else:
pygame.draw.rect(display, (255, 80, 80), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))
```
Similarly let's add fuel rod
```python
for fuel_rod in core.get_fuel_rod_list():
for fuel_element in fuel_rod.get_fuel_elements():
pos = fuel_element.get_body().position
pos = int(pos.x), int(pos.y)
if fuel_element.get_material() == Material.FISSILE:
# blue for fissile material
pygame.draw.circle(display,(48, 121, 203), pos, int(fuel_element.get_radius()))
elif fuel_element.get_material() == Material.NON_FISSILE:
# dark grey for non-fissile material
pygame.draw.circle(display, (187, 187, 187), pos, int(fuel_element.get_radius()))
elif fuel_element.get_material() == Material.XENON:
# black for xenon
pygame.draw.circle(display, (0, 0, 0), pos, int(fuel_element.get_radius()))
```
It is highly probable for a neutron to cause fission when it's speed is within a threshold to thermal speed.
These speeds are Vec2D and `neutron_body.velocity` is Vec2D and `neutrong_body.velocity.length` gives magnitude of the Vec2D.
```python
# Get the neutron's current position (convert pymunk's coordinate system to pygame's)
for neutron in core.get_neutron_list():
pos = neutron.get_body().position
pos = int(pos.x), int(pos.y)
neutron_body = neutron.get_body()
threshold = 0.5
if (neutron_body.velocity.length - core.thermal_speed.length) <= threshold:
# red color for thermal neutron
pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius())
else:
# red outline for slow neutron
pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius(), 2)
```
Adding Moderator and Control Rods (Allowing Control Rod to react to Keyboard Up and Down keys)
```python
for moderator in core.get_moderator_list():
pos = moderator.get_body().position
pos = int(pos.x), int(pos.y)
pygame.draw.rect(display, (0, 0, 0), (pos[0] - moderator.get_length() // 2, pos[1] - moderator.width // 2, moderator.get_length(), moderator.width), 1)
keys = pygame.key.get_pressed()
movement = 0
if keys[pygame.K_UP]:
movement = -1
elif keys[pygame.K_DOWN]:
movement = 1
for control_rod in core.get_control_rod_list():
control_rod.move_control_rod(movement)
pos = control_rod.get_body().position
pos = int(pos.x), int(pos.y)
pygame.draw.rect(display, (128, 128, 128), (pos[0] - control_rod.get_length() // 2, pos[1] - control_rod.width // 2, control_rod.get_length(), control_rod.width))
```
Now it's time to update our simulation both pygame canvas as well as core simulation
```python
pygame.display.update()
clock.tick(FPS)
# Run the physics simulation
mechanics.generate_random_neutron(limit=0.08)
mechanics.regulate_water_temperature()
mechanics.regulate_fuel_element_occurence()
# Step the physics simulation
core.get_space().step(1 / FPS)
```
Calling the game function
```python
game()
pygame.quit()
```
![Sample](media/media_sample.gif)
Hence the complete code would kinda look this
```python
import pygame
from fissionmunk import Core
from fissionmunk import Moderator
from fissionmunk import ControlRod
from fissionmunk import Fuel
from fissionmunk import Water
from fissionmunk import Material
from fissionmunk import Mechanics
# Initialize Pygame
pygame.init()
display = pygame.display.set_mode((700, 600))
clock = pygame.time.Clock()
FPS = 60
# Create a core object
core = Core(length=700, width=600,thermal_factor=4, cold_factor=1, fast_factor=10)
moderator = Moderator(length=10, width=580, position=(600, 290), material=Material.GRAPHITE)
core.add_moderator_to_core(moderator)
control_rod = ControlRod(length=10, width=600, position=(500, 0), tag="E", movement_range=[20, 580],material=Material.BORON_CARBIDE)
core.add_control_rod_to_core(control_rod)
fuel_rod = Fuel(fuel_element_gap=10,uranium_occurance_probability=0.0001, xenon_occurance_probability=0.00001, xenon_decay_probability=0.00001, element_radius=10, width=560, position=(300, 25))
core.add_fuel_rod_to_core(fuel_rod)
for j in range(25, 580, 30):
water = Water(length=25, width=25, position=(450, j), coolant=True, hard_limit=30, temperature_threshold=100, material=Material.WATER)
core.add_water_to_core(water)
# Create a mechanics object
mechanics = Mechanics(core)
def game():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
display.fill((255, 255, 255))
for water in core.get_water_list():
pos = water.get_body().position
pos = int(pos.x), int(pos.y)
if water.removed:
pygame.draw.rect(display, (255, 255, 255), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))
else:
pygame.draw.rect(display, (255, 80, 80), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))
for fuel_rod in core.get_fuel_rod_list():
for fuel_element in fuel_rod.get_fuel_elements():
pos = fuel_element.get_body().position
pos = int(pos.x), int(pos.y)
if fuel_element.get_material() == Material.FISSILE:
# blue for fissile material
pygame.draw.circle(display,(48, 121, 203), pos, int(fuel_element.get_radius()))
elif fuel_element.get_material() == Material.NON_FISSILE:
# dark grey for non-fissile material
pygame.draw.circle(display, (187, 187, 187), pos, int(fuel_element.get_radius()))
elif fuel_element.get_material() == Material.XENON:
# black for xenon
pygame.draw.circle(display, (0, 0, 0), pos, int(fuel_element.get_radius()))
# Get the neutron's current position (convert pymunk's coordinate system to pygame's)
for neutron in core.get_neutron_list():
pos = neutron.get_body().position
pos = int(pos.x), int(pos.y)
threshold = 0.5
if (neutron.body.velocity.length - core.thermal_speed.length) <= threshold:
# red color for thermal neutron
pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius())
else:
# red outline for slow neutron
pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius(), 2)
for moderator in core.get_moderator_list():
pos = moderator.get_body().position
pos = int(pos.x), int(pos.y)
pygame.draw.rect(display, (0, 0, 0), (pos[0] - moderator.get_length() // 2, pos[1] - moderator.width // 2, moderator.get_length(), moderator.width), 1)
keys = pygame.key.get_pressed()
movement = 0
if keys[pygame.K_UP]:
movement = -1
elif keys[pygame.K_DOWN]:
movement = 1
for control_rod in core.get_control_rod_list():
control_rod.move_control_rod(movement)
pos = control_rod.get_body().position
pos = int(pos.x), int(pos.y)
pygame.draw.rect(display, (128, 128, 128), (pos[0] - control_rod.get_length() // 2, pos[1] - control_rod.width // 2, control_rod.get_length(), control_rod.width))
pygame.display.update()
clock.tick(FPS)
# Run the physics simulation
mechanics.generate_random_neutron(limit=0.08)
mechanics.regulate_water_temperature()
mechanics.regulate_fuel_element_occurence()
# Step the physics simulation
core.get_space().step(1 / FPS)
game()
pygame.quit()
```
Congrats! You just made your first simulation using Fissionmunk.
Well even though it doesnt quite look like a reactor but you can play around with it add more control rods and moderators and it will start resembling close to a 2D representation of a nuclear reactor
### Documentation Overview
The following modules are included in FissionMunk and offer various simulation controls:
- **Core**: Manages the main simulation environment and fuel elements.
- **ControlRod**: Controls neutron absorption, allowing for fission rate adjustments.
- **Moderator**: Slows down neutrons to maintain optimal reaction rates.
- **FuelElement**: Represents fuel elements, such as uranium atoms, in the simulation.
- **Neutron**: Models individual neutrons and their interactions.
Refer to the full documentation for module-specific details and usage examples.
## Contributing
We welcome contributions to the FissionMunk project! If you'd like to contribute, please follow these steps:
1. **Fork** this repository to your own GitHub account.
2. **Create a new branch** from the `main` branch for your feature or fix. You can name the branch something descriptive, like `feature/your-feature-name`.
3. **Commit your changes** with clear and concise commit messages.
4. **Push your branch** to your forked repository.
5. **Open a pull request** (PR) to the main repository. Be sure to provide a description of the changes you've made.
### Major Changes
If you're planning on making a major change or addition, please **open an issue** first to discuss your ideas with the maintainers before starting on the implementation. This helps ensure that your changes align with the project's goals.
Thank you for contributing!
## License
[MIT License](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/iAniket23/fissionmunk",
"name": "fissionmunk",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "fission, nuclear, physics, simulation, reactor, 2D, python, library, open-source, pymunk, ianiket23",
"author": "Aniket Mishra",
"author_email": "ianiket23@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9f/4c/50f97d8b4574dcd930b82352da2526b9eb4dfedf812b4d3c4cd4c621550f/fissionmunk-0.0.4.tar.gz",
"platform": null,
"description": "# FissionMunk\n\n![Python Version](https://img.shields.io/badge/python-3.8%2B-blue)\n![License](https://img.shields.io/badge/license-MIT-green)\n![PyPI version](https://badge.fury.io/py/fissionmunk.svg)\n[![API Reference](https://img.shields.io/badge/API%20Reference-Docs-blue)](https://ianiket23.github.io/FissionMunk/)\n\n**FissionMunk** is a lightweight 2D physics open source python library designed to simulate nuclear fission reactor mechanics. It enables users to visualize interactions between neutrons and uranium atoms, providing valuable insights into fission dynamics with customizable parameters, such as neutron occurrence probabilities, moderators, and control rods. FissionMunk is ideal for educational simulations, nuclear physics research, and interactive demos, and is built on top of the [Pymunk](http://www.pymunk.org/) library.\n\n2024, Aniket Mishra - [ianiket23@github.io](https://ianiket23.github.io/)\n\n- **Documentation**: [https://ianiket23.github.io/FissionMunk/](https://ianiket23.github.io/FissionMunk/)\n- **Source code**: [https://github.com/iAniket23/fissionmunk](https://github.com/iAniket23/fissionmunk) \n- **PyPI**: [https://pypi.org/project/fissionmunk/](https://pypi.org/project/fissionmunk/)\n- **Bug reports**: [https://github.com/iAniket23/fissionmunk/issues](https://github.com/iAniket23/fissionmunk/issues) \n\n## Features\n- Interactive Simulation: Visualize neutron interactions with uranium in real-time, with configurable parameters.\n- Modularity: Use customizable modules to add moderators, control rods, and other reactor elements.\n- Educational Tool: Ideal for students and educators to explore nuclear fission mechanics.\n- Open-Source: Fully open-source and extensible for customization and additional functionality.\n\n## Getting Started with FissionMunk\nFissionMunk makes it easy to simulate and visualize nuclear fission dynamics.\n![rbmk](media/media_rbmk.gif)\n\nTo get started, follow these steps:\n\n### Installation\n\nTo install FissionMunk, use `pip`:\n```bash\npip install fissionmunk\n```\n### Set Up Your First Simulation\nNow that you\u2019ve installed FissionMunk, let's create a very basic simulation. First let's install a visualization library such as pygame (`pip install pygame`).\nHere's an example to help you get started:\n\n#### Example: Basic Fission Simulation\nNow let's start by importing these libraries\n```python\nimport pygame\n\nfrom fissionmunk import Core\nfrom fissionmunk import Moderator\nfrom fissionmunk import ControlRod\nfrom fissionmunk import Fuel\nfrom fissionmunk import Water\nfrom fissionmunk import Material\nfrom fissionmunk import Mechanics\n```\n\nInitialize a display canvas using pygame\n```python\n# Initialize Pygame\npygame.init()\ndisplay = pygame.display.set_mode((700, 600))\nclock = pygame.time.Clock()\nFPS = 60\n```\nNow moving onto some fun stuff with Fissionmunk. In order to do simulation with fissionmunk we need to have some key items.\n\n- **Core**: Manages the main simulation environment and fuel elements.\n- **ControlRod**: Controls neutron absorption, allowing for fission rate adjustments.\n- **Moderator**: Slows down neutrons to maintain optimal reaction rates.\n- **FuelElement**: Represents fuel elements, such as uranium atoms, in the simulation.\n- **Neutron**: Models individual neutrons and their interactions.\n\nOne thing to keep in mind is that we can tweak the probability of the occurance of the Fuel elements in a fuel rod.\nUranium-235 doesn't just occur all of a sudden in a rod but for the sake of the simulation we can pretend that Uranium-235 randomly occurs (refuel) in the rod.\n```python\n# Create a core object\ncore = Core(length=700, width=600,thermal_factor=4, cold_factor=1, fast_factor=10)\n\nmoderator = Moderator(length=10, width=580, position=(600, 290), material=Material.GRAPHITE)\n\ncontrol_rod = ControlRod(length=10, width=600, position=(500, 0), tag=\"E\", movement_range=[20, 580],material=Material.BORON_CARBIDE)\n\nfuel_rod = Fuel(fuel_element_gap=10,uranium_occurance_probability=0.0001, xenon_occurance_probability=0.00001, xenon_decay_probability=0.00001, element_radius=10, width=560, position=(300, 25))\n```\nWe have initialized these reactor objects, and now it's time to actually add these in our Core.\n\n```python\ncore.add_moderator_to_core(moderator)\n\ncore.add_control_rod_to_core(control_rod)\n\ncore.add_fuel_rod_to_core(fuel_rod)\n```\nNow let's add some water in our core. Water has some unique properties in the reactor. It acts as a neutron poison, as in, it absorbs neutron. One more property water have is temperature. More fission equals more heat which results in making the water heat up (ultimately resulting in water evaporating).\n\nNow let's rather than making a big water rod, for the sake of our sample example, let's make a grid of water squares.\n```python\nfor j in range(25, 580, 30):\n water = Water(length=25, width=25, position=(450, j), coolant=True, hard_limit=30, temperature_threshold=100, material=Material.WATER)\n core.add_water_to_core(water)\n```\nNow in order to handle all the collisions and properties (like regulating water temperature and random neutron generation). We need have\nMechanic object attached to our Core\n```python\nmechanics = Mechanics(core)\n```\n\nNow it's time to go to our pygame loop and draw objects.\n```python\ndef game():\n while True:\n for event in pygame.event.get():\n if event.type == pygame.QUIT:\n return\n\n display.fill((255, 255, 255))\n```\nNow let's grab the water in our core and draw it. We draw the water only if it is not removed (evaporated) cause of high temperature.\n```python\n for water in core.get_water_list():\n pos = water.get_body().position\n pos = int(pos.x), int(pos.y)\n if water.removed:\n pygame.draw.rect(display, (255, 255, 255), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))\n else:\n pygame.draw.rect(display, (255, 80, 80), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))\n```\nSimilarly let's add fuel rod\n```python\n for fuel_rod in core.get_fuel_rod_list():\n for fuel_element in fuel_rod.get_fuel_elements():\n pos = fuel_element.get_body().position\n pos = int(pos.x), int(pos.y)\n if fuel_element.get_material() == Material.FISSILE:\n # blue for fissile material\n pygame.draw.circle(display,(48, 121, 203), pos, int(fuel_element.get_radius()))\n\n elif fuel_element.get_material() == Material.NON_FISSILE:\n # dark grey for non-fissile material\n pygame.draw.circle(display, (187, 187, 187), pos, int(fuel_element.get_radius()))\n\n elif fuel_element.get_material() == Material.XENON:\n # black for xenon\n pygame.draw.circle(display, (0, 0, 0), pos, int(fuel_element.get_radius()))\n```\nIt is highly probable for a neutron to cause fission when it's speed is within a threshold to thermal speed.\nThese speeds are Vec2D and `neutron_body.velocity` is Vec2D and `neutrong_body.velocity.length` gives magnitude of the Vec2D.\n```python\n # Get the neutron's current position (convert pymunk's coordinate system to pygame's)\n for neutron in core.get_neutron_list():\n pos = neutron.get_body().position\n pos = int(pos.x), int(pos.y)\n neutron_body = neutron.get_body()\n threshold = 0.5\n if (neutron_body.velocity.length - core.thermal_speed.length) <= threshold:\n # red color for thermal neutron\n pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius())\n else:\n # red outline for slow neutron\n pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius(), 2)\n```\nAdding Moderator and Control Rods (Allowing Control Rod to react to Keyboard Up and Down keys)\n```python\n for moderator in core.get_moderator_list():\n pos = moderator.get_body().position\n pos = int(pos.x), int(pos.y)\n pygame.draw.rect(display, (0, 0, 0), (pos[0] - moderator.get_length() // 2, pos[1] - moderator.width // 2, moderator.get_length(), moderator.width), 1)\n\n keys = pygame.key.get_pressed()\n\n movement = 0\n if keys[pygame.K_UP]:\n movement = -1\n elif keys[pygame.K_DOWN]:\n movement = 1\n\n for control_rod in core.get_control_rod_list():\n\n control_rod.move_control_rod(movement)\n pos = control_rod.get_body().position\n pos = int(pos.x), int(pos.y)\n pygame.draw.rect(display, (128, 128, 128), (pos[0] - control_rod.get_length() // 2, pos[1] - control_rod.width // 2, control_rod.get_length(), control_rod.width))\n```\n\nNow it's time to update our simulation both pygame canvas as well as core simulation\n```python\n pygame.display.update()\n clock.tick(FPS)\n\n # Run the physics simulation\n mechanics.generate_random_neutron(limit=0.08)\n mechanics.regulate_water_temperature()\n mechanics.regulate_fuel_element_occurence()\n\n # Step the physics simulation\n core.get_space().step(1 / FPS)\n```\nCalling the game function\n```python\ngame()\npygame.quit()\n```\n![Sample](media/media_sample.gif)\n\nHence the complete code would kinda look this\n```python\nimport pygame\n\nfrom fissionmunk import Core\nfrom fissionmunk import Moderator\nfrom fissionmunk import ControlRod\nfrom fissionmunk import Fuel\nfrom fissionmunk import Water\nfrom fissionmunk import Material\n\nfrom fissionmunk import Mechanics\n\n# Initialize Pygame\npygame.init()\ndisplay = pygame.display.set_mode((700, 600))\nclock = pygame.time.Clock()\nFPS = 60\n\n# Create a core object\ncore = Core(length=700, width=600,thermal_factor=4, cold_factor=1, fast_factor=10)\n\n\nmoderator = Moderator(length=10, width=580, position=(600, 290), material=Material.GRAPHITE)\ncore.add_moderator_to_core(moderator)\n\n\ncontrol_rod = ControlRod(length=10, width=600, position=(500, 0), tag=\"E\", movement_range=[20, 580],material=Material.BORON_CARBIDE)\ncore.add_control_rod_to_core(control_rod)\n\nfuel_rod = Fuel(fuel_element_gap=10,uranium_occurance_probability=0.0001, xenon_occurance_probability=0.00001, xenon_decay_probability=0.00001, element_radius=10, width=560, position=(300, 25))\ncore.add_fuel_rod_to_core(fuel_rod)\n\n\nfor j in range(25, 580, 30):\n water = Water(length=25, width=25, position=(450, j), coolant=True, hard_limit=30, temperature_threshold=100, material=Material.WATER)\n core.add_water_to_core(water)\n\n# Create a mechanics object\nmechanics = Mechanics(core)\n\ndef game():\n while True:\n for event in pygame.event.get():\n if event.type == pygame.QUIT:\n return\n\n display.fill((255, 255, 255))\n\n for water in core.get_water_list():\n pos = water.get_body().position\n pos = int(pos.x), int(pos.y)\n if water.removed:\n pygame.draw.rect(display, (255, 255, 255), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))\n else:\n pygame.draw.rect(display, (255, 80, 80), (pos[0] - water.length // 2, pos[1] - water.width // 2, water.length, water.width))\n\n for fuel_rod in core.get_fuel_rod_list():\n for fuel_element in fuel_rod.get_fuel_elements():\n pos = fuel_element.get_body().position\n pos = int(pos.x), int(pos.y)\n if fuel_element.get_material() == Material.FISSILE:\n # blue for fissile material\n pygame.draw.circle(display,(48, 121, 203), pos, int(fuel_element.get_radius()))\n\n elif fuel_element.get_material() == Material.NON_FISSILE:\n # dark grey for non-fissile material\n pygame.draw.circle(display, (187, 187, 187), pos, int(fuel_element.get_radius()))\n\n elif fuel_element.get_material() == Material.XENON:\n # black for xenon\n pygame.draw.circle(display, (0, 0, 0), pos, int(fuel_element.get_radius()))\n\n # Get the neutron's current position (convert pymunk's coordinate system to pygame's)\n for neutron in core.get_neutron_list():\n pos = neutron.get_body().position\n pos = int(pos.x), int(pos.y)\n threshold = 0.5\n if (neutron.body.velocity.length - core.thermal_speed.length) <= threshold:\n # red color for thermal neutron\n pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius())\n else:\n # red outline for slow neutron\n pygame.draw.circle(display, (255, 0, 0), pos, neutron.get_radius(), 2)\n\n for moderator in core.get_moderator_list():\n pos = moderator.get_body().position\n pos = int(pos.x), int(pos.y)\n pygame.draw.rect(display, (0, 0, 0), (pos[0] - moderator.get_length() // 2, pos[1] - moderator.width // 2, moderator.get_length(), moderator.width), 1)\n\n keys = pygame.key.get_pressed()\n\n movement = 0\n if keys[pygame.K_UP]:\n movement = -1\n elif keys[pygame.K_DOWN]:\n movement = 1\n\n for control_rod in core.get_control_rod_list():\n\n control_rod.move_control_rod(movement)\n pos = control_rod.get_body().position\n pos = int(pos.x), int(pos.y)\n pygame.draw.rect(display, (128, 128, 128), (pos[0] - control_rod.get_length() // 2, pos[1] - control_rod.width // 2, control_rod.get_length(), control_rod.width))\n\n pygame.display.update()\n clock.tick(FPS)\n\n # Run the physics simulation\n mechanics.generate_random_neutron(limit=0.08)\n mechanics.regulate_water_temperature()\n mechanics.regulate_fuel_element_occurence()\n\n # Step the physics simulation\n core.get_space().step(1 / FPS)\n\ngame()\npygame.quit()\n```\n\nCongrats! You just made your first simulation using Fissionmunk.\nWell even though it doesnt quite look like a reactor but you can play around with it add more control rods and moderators and it will start resembling close to a 2D representation of a nuclear reactor\n\n### Documentation Overview\nThe following modules are included in FissionMunk and offer various simulation controls:\n\n- **Core**: Manages the main simulation environment and fuel elements.\n- **ControlRod**: Controls neutron absorption, allowing for fission rate adjustments.\n- **Moderator**: Slows down neutrons to maintain optimal reaction rates.\n- **FuelElement**: Represents fuel elements, such as uranium atoms, in the simulation.\n- **Neutron**: Models individual neutrons and their interactions.\n\nRefer to the full documentation for module-specific details and usage examples.\n\n## Contributing\n\nWe welcome contributions to the FissionMunk project! If you'd like to contribute, please follow these steps:\n\n1. **Fork** this repository to your own GitHub account.\n2. **Create a new branch** from the `main` branch for your feature or fix. You can name the branch something descriptive, like `feature/your-feature-name`.\n3. **Commit your changes** with clear and concise commit messages.\n4. **Push your branch** to your forked repository.\n5. **Open a pull request** (PR) to the main repository. Be sure to provide a description of the changes you've made.\n\n### Major Changes\nIf you're planning on making a major change or addition, please **open an issue** first to discuss your ideas with the maintainers before starting on the implementation. This helps ensure that your changes align with the project's goals.\n\nThank you for contributing!\n\n## License\n[MIT License](LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "FissionMunk is a lightweight 2D physics open source python library designed to simulate nuclear fission reactor mechanics.",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/iAniket23/fissionmunk",
"Repository": "https://github.com/iAniket23/fissionmunk"
},
"split_keywords": [
"fission",
" nuclear",
" physics",
" simulation",
" reactor",
" 2d",
" python",
" library",
" open-source",
" pymunk",
" ianiket23"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3a4b9b6bf5eb318af9d1f5060bd86598d96dcf1edbc21140f0e4704b07f34ec0",
"md5": "2be983884946c4eac180d615c0759b50",
"sha256": "f45edfb73b878de4d3525fecb144ef15f73d7d6892ee817fbdc13163c49c2700"
},
"downloads": -1,
"filename": "fissionmunk-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2be983884946c4eac180d615c0759b50",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 17928,
"upload_time": "2024-11-16T22:11:11",
"upload_time_iso_8601": "2024-11-16T22:11:11.179586Z",
"url": "https://files.pythonhosted.org/packages/3a/4b/9b6bf5eb318af9d1f5060bd86598d96dcf1edbc21140f0e4704b07f34ec0/fissionmunk-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9f4c50f97d8b4574dcd930b82352da2526b9eb4dfedf812b4d3c4cd4c621550f",
"md5": "13cbd3f5e3a561727ed04e1cfbdecec1",
"sha256": "80eb492d5a8e10435f09fbb91fb3900413d17c5f8951ab5a435edf27cabccd29"
},
"downloads": -1,
"filename": "fissionmunk-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "13cbd3f5e3a561727ed04e1cfbdecec1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 17264,
"upload_time": "2024-11-16T22:11:13",
"upload_time_iso_8601": "2024-11-16T22:11:13.028315Z",
"url": "https://files.pythonhosted.org/packages/9f/4c/50f97d8b4574dcd930b82352da2526b9eb4dfedf812b4d3c4cd4c621550f/fissionmunk-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-16 22:11:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "iAniket23",
"github_project": "fissionmunk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "fissionmunk"
}