Spaces:
Runtime error
Runtime error
| from pathlib import Path | |
| from deepengineer.backend.gradio_tools import parse_markdown_images | |
| from deepengineer.deepsearch.main_agent import create_output_image_path | |
| markdown = """ | |
| # Nuclear Reactor: Structure and Components | |
| A nuclear reactor is a complex system designed to initiate and control a sustained nuclear chain reaction. The primary purpose of a | |
| nuclear reactor is to generate heat through nuclear fission, which is then used to produce electricity. Below is a detailed explanation | |
| of the main components and their functions, along with a simplified diagram. | |
| ## Simplified Diagram of a Nuclear Reactor | |
|  | |
| ## Main Components and Their Functions | |
| ### 1. Reactor Core | |
| The reactor core is the central part of the nuclear reactor where nuclear fission occurs. It contains: | |
| - **Nuclear Fuel**: Typically uranium oxide pellets arranged in fuel rods. | |
| - **Control Rods**: Made of materials like cadmium or boron, these rods absorb neutrons and regulate the fission rate. | |
| - **Moderator**: A material (often water) that slows down neutrons to sustain the chain reaction. | |
| ### 2. Pressure Vessel | |
| A robust container that houses the reactor core and coolant under high pressure. It ensures the integrity and safety of the reactor core. | |
| ### 3. Coolant | |
| A fluid (usually water) that circulates through the core to absorb the heat generated by fission. The heated coolant is then used to | |
| produce steam. | |
| ### 4. Steam Generator | |
| The heat from the coolant is transferred to a secondary water loop, which turns into steam. This steam is used to drive turbines. | |
| ### 5. Turbine | |
| The steam produced in the steam generator is directed onto the blades of a turbine, causing it to spin. The turbine is connected to a | |
| generator, which produces electricity. | |
| ### 6. Cooling Tower | |
| Excess heat that is not converted into electricity is dissipated in the cooling tower. The cooling tower releases this heat into the | |
| atmosphere. | |
| ### 7. Containment Structure | |
| A steel-reinforced concrete dome or enclosure that isolates the reactor from the environment. It is designed to contain any radioactive | |
| materials and prevent their release. | |
| ## How a Nuclear Reactor Works | |
| 1. **Nuclear Fission**: In the reactor core, uranium atoms undergo fission, releasing a significant amount of heat energy. | |
| 2. **Heat Transfer**: The coolant absorbs this heat and transfers it to the steam generator. | |
| 3. **Steam Production**: In the steam generator, water is converted into steam using the heat from the coolant. | |
| 4. **Electricity Generation**: The steam drives the turbine, which is connected to a generator, producing electricity. | |
| 5. **Cooling**: Excess heat is dissipated in the cooling tower, and the cycle repeats. | |
| ## Sources | |
| - [World Nuclear Association - Nuclear Power | |
| Reactors](https://world-nuclear.org/information-library/nuclear-fuel-cycle/nuclear-power-reactors/nuclear-power-reactors.aspx) | |
| - [Britannica - Nuclear Reactor](https://www.britannica.com/technology/nuclear-reactor) | |
| - [U.S. Department of Energy - How Does a Nuclear Reactor | |
| Work?](https://www.energy.gov/ne/articles/nuclear-101-how-does-nuclear-reactor-work) | |
| - [Wikipedia - Nuclear Reactor](https://en.wikipedia.org/wiki/Nuclear_reactor) | |
| - [BYJU'S - Introduction to Nuclear Reactor](https://byjus.com/physics/nuclear-reactor-based-on-nuclear-fission/) | |
| This simplified diagram and explanation provide a basic understanding of the structure and function of a nuclear reactor. | |
| """ | |
| def test_parse_markdown_images(): | |
| image_dir = create_output_image_path(4351840) | |
| real_image_path = image_dir / "nuclear_reactor_diagram.png" | |
| output_image_path = "data/images_4351840/nuclear_reactor_diagram.png" | |
| assert real_image_path.exists() | |
| parsed_markdown = parse_markdown_images(markdown, image_dir) | |
| assert output_image_path in parsed_markdown | |