Пример #1
0
        /// <summary>回路網テスト1</summary>
        /// <remarks>2節点の流量計算</remarks>
        private static void circuitTest1()
        {
            //節点作成
            Node node1 = new Node("SampleNode1", 0, 10);
            Node node2 = new Node("SampleNode2", 0, 0);

            //流路作成・接続
            Channel channel = new Channel("SampleChannel", 2, 1.2);
            channel.Connect(node1, node2);

            //流量計算
            double flow = channel.GetFlow();

            Console.WriteLine("流量 : " + flow);
            Console.Read();
        }
Пример #2
0
        /// <summary>回路網テスト2</summary>
        /// <remarks>水回路の水量計算</remarks>
        private static void circuitTest2()
        {
            //設備基礎理論pp.337より***********************************************
            //      ------A------
            //      |           |
            //  ->--1--B--2--C--3-->-
            //            |     |
            //            ---D--
            Circuit circuit = new Circuit("水回路の水量計算");

            //節点追加
            ImmutableNode node1 = circuit.AddNode(new Node("1", 0, 0));
            ImmutableNode node2 = circuit.AddNode(new Node("2", 0, 0));
            ImmutableNode node3 = circuit.AddNode(new Node("3", 0, 0));

            //流路作成
            Channel chA = new Channel("A", 167, 2);
            Channel chB = new Channel("B", 192, 2);
            Channel chC = new Channel("C", 840, 2);
            Channel chD = new Channel("D", 4950, 2);
            //外部の系への流出流量
            circuit.SetExternalFlow(-7.06, node1);
            circuit.SetExternalFlow(7.06, node3);

            //接続処理
            ImmutableChannel channelA = circuit.ConnectNodes(node1, node3, chA);
            ImmutableChannel channelB = circuit.ConnectNodes(node1, node2, chB);
            ImmutableChannel channelC = circuit.ConnectNodes(node2, node3, chC);
            ImmutableChannel channelD = circuit.ConnectNodes(node2, node3, chD);

            //ソルバを用意
            CircuitSolver cSolver = new CircuitSolver(circuit);
            cSolver.Solve();
            Console.WriteLine("流路A流量:" + channelA.GetFlow());
            Console.WriteLine("流路B流量:" + channelB.GetFlow());
            Console.WriteLine("流路C流量:" + channelC.GetFlow());
            Console.WriteLine("流路D流量:" + channelD.GetFlow());
            Console.Read();
        }
Пример #3
0
        /// <summary>Circuit test 2</summary>
        /// <remarks>Calculating water pipe network</remarks>
        private static void circuitTest2()
        {
            Circuit circuit = new Circuit("Circuit network of water pipe");

            //Add nodes to circuit network
            ImmutableNode node1 = circuit.AddNode(new Node("1", 0, 0));
            ImmutableNode node2 = circuit.AddNode(new Node("2", 0, 0));
            ImmutableNode node3 = circuit.AddNode(new Node("3", 0, 0));
            //Set external water flow
            circuit.SetExternalFlow(-7.06, node1);
            circuit.SetExternalFlow(7.06, node3);

            //Create channels
            Channel chA = new Channel("A", 167, 2);
            Channel chB = new Channel("B", 192, 2);
            Channel chC = new Channel("C", 840, 2);
            Channel chD = new Channel("D", 4950, 2);

            //Connect nodes with channels
            ImmutableChannel channelA = circuit.ConnectNodes(node1, node3, chA);
            ImmutableChannel channelB = circuit.ConnectNodes(node1, node2, chB);
            ImmutableChannel channelC = circuit.ConnectNodes(node2, node3, chC);
            ImmutableChannel channelD = circuit.ConnectNodes(node2, node3, chD);

            //Create solver
            CircuitSolver cSolver = new CircuitSolver(circuit);
            cSolver.Solve();
            Console.WriteLine("Water flow A is " + channelA.GetFlow().ToString("F2"));
            Console.WriteLine("Water flow B is " + channelB.GetFlow().ToString("F2"));
            Console.WriteLine("Water flow C is " + channelC.GetFlow().ToString("F2"));
            Console.WriteLine("Water flow D is " + channelD.GetFlow().ToString("F2"));
            Console.Read();
        }
Пример #4
0
        /// <summary>節点を接続する</summary>
        /// <param name="node1">節点1</param>
        /// <param name="node2">節点2</param>
        /// <param name="channel">接続に使用する流路</param>
        /// <returns>接続した流路(Clone処理を行うため<paramref name="channel"/>とは異なる)</returns>
        public ImmutableChannel ConnectNodes(ImmutableNode node1, ImmutableNode node2, Channel channel)
        {
            //節点存在確認
            Node nd1 = getNode(node1);
            Node nd2 = getNode(node2);
            if (nd1 == null || nd2 == null) return null;

            //流路を複製してIDを付与
            Channel newChannel = (Channel)channel.Clone();
            newChannel.ID = channels.Count;

            //接続処理
            newChannel.Connect(nd1, nd2);
            //リストに追加
            this.channels.Add(newChannel);

            //イベント通知
            if (NodeConnectEvent != null) NodeConnectEvent(this, new NodeConnectionEventArgs(nd1, nd2, newChannel));

            return newChannel;
        }
Пример #5
0
        /// <summary>Circuit test 1</summary>
        /// <remarks>Calculating energy flow between two nodes</remarks>
        private static void circuitTest1()
        {
            //Create new instance of Node class.
            Node node1 = new Node("SampleNode1", 0, 10);
            Node node2 = new Node("SampleNode2", 0, 0);

            //Create new instance of Channel class and connect nodes.
            Channel channel = new Channel("SampleChannel", 2, 1.2);
            channel.Connect(node1, node2);

            //Calculate energy flow.
            double flow = channel.GetFlow();

            Console.WriteLine("Energy flow is : " + flow.ToString("F2"));
            Console.Read();
        }