Files
BWRSimlator/BWR.ConsoleApp/Program.cs

57 lines
2.8 KiB
C#

// MyBWRSimulator.ConsoleApp/Program.cs
namespace MyBWRSimulator.ConsoleApp
{
using MyBWRSimulator.Core.Simulation;
using MyBWRSimulator.Core.Components.Concrete; // Needed for specific component instantiation if not using config
using MyBWRSimulator.Core.Ports; // Needed for specific port instantiation if not using config
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting BWR Simulator Console Application...");
var simulator = new Simulator();
// Define the path to your configuration file
// Adjust this path as needed for your project structure
string configFilePath = Path.Combine(Directory.GetCurrentDirectory(), "config", "PlantConfig.json");
// Option 1: Load configuration from JSON file
//simulator.LoadPlantConfiguration(configFilePath);
// Option 2 (Alternative for testing without config file): Manually create components and connect them
var reactor = new ReactorCore("RC001", "Main Reactor Core", 4);
var pump = new Pump("PMP001", "Recirculation Pump", 100.0, 50000.0); // maxFlow, maxHeadPressure
var pipe = new Pipe("PIP001", "Hot Leg Pipe", 20.0, 0.5); // length, diameter
var tank = new FluidTank("TK001", "Condensate Tank", 500.0, 1, 1, 250.0); // maxVol, numInlets, numOutlets, initialVol
simulator.AddComponent(reactor);
simulator.AddComponent(pump);
simulator.AddComponent(pipe);
simulator.AddComponent(tank);
// Establish connections manually (example)
// Note: You'd need to access the specific ports of each component.
// This is simplified and assumes direct port access for brevity.
// In a real scenario, you'd use GetFluidPorts() etc.
// For example: pump.GetThermalPorts().First(p => p.ID.Contains("PowerIn")).Connect(powerSource.GetThermalPorts().First(p => p.ID.Contains("PowerOut")));
// Example of manual connection (requires casting and knowing port IDs)
// This is simplified and might break if port IDs change.
// The ConfigurationLoader handles this more robustly.
reactor.GetFluidPortById("FeedwaterInlet").Connect(pipe.GetFluidPortById("Inlet"));
pipe.GetFluidPortById("Outlet").Connect(pump.GetFluidPortById("Inlet"));
pump.GetFluidPortById("Outlet").Connect(tank.GetFluidPortById("Outlet")); // Tank has Inlet1, Inlet2 etc.
// Run the simulation for 60 seconds with 1-second time steps
simulator.RunSimulation(60.0, 1.0);
Console.WriteLine("\nSimulation application finished. Press any key to exit.");
Console.ReadKey();
}
}
}