Exemple #1
0
        static void Main(string[] args)
        {
            //DEBUG
            //args = new string[] { "inputs.csv" };

            if (args.Length == 0)
            {
                Console.WriteLine("Specify a filename (ex. inputs.csv)");
                return;
            }
            string filePath = args[0];
            if (! File.Exists(filePath))
            {
                Console.WriteLine("File '" + filePath + "' doesn't exist.");
                return;
            }

            //Make output file
            string oFilePath = filePath.Remove(filePath.LastIndexOf('.')) + "_Result.csv";

            //Read input file
            using (StreamReader sReader = new StreamReader(filePath))
            using(StreamWriter sWriter = new StreamWriter(oFilePath, false, Encoding.GetEncoding("Shift_JIS")))
            {
                //Read "weight"
                double weight = double.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "height"
                double height = double.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "age"
                double age = double.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "sex"
                bool isMale = bool.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "cardiac index at rest"
                double ci = double.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "fat percentage"
                double fat = double.Parse(sReader.ReadLine().Split(',')[1]);
                //Read "output time span"
                double oSpan = double.Parse(sReader.ReadLine().Split(',')[1]);

                //Make an instance of HumanBody class
                HumanBody body = new HumanBody(weight, height, age, isMale, ci, fat);
                //Output informations
                outputData(sWriter, body, 0, true);
                outputData(sWriter, body, 0, false);

                sReader.ReadLine();
                sReader.ReadLine();

                //Start iteration
                double cTime = 0;
                double time =0;
                double nextTime = 0;
                Dictionary<HumanBody.Nodes, double> dbTemp = new Dictionary<HumanBody.Nodes, double>();  //乾球温度
                Dictionary<HumanBody.Nodes, double> mrTemp = new Dictionary<HumanBody.Nodes, double>(); //平均放射温度
                Dictionary<HumanBody.Nodes, double> vels = new Dictionary<HumanBody.Nodes, double>();   //気流速度
                Dictionary<HumanBody.Nodes, double> rHumid = new Dictionary<HumanBody.Nodes, double>(); //相対湿度
                Dictionary<HumanBody.Nodes, double> matTemp = new Dictionary<HumanBody.Nodes, double>();//物体温度
                Dictionary<HumanBody.Nodes, double> conRate = new Dictionary<HumanBody.Nodes, double>();//接触割合
                Dictionary<HumanBody.Nodes, double> conduct = new Dictionary<HumanBody.Nodes, double>();//接触部の熱コンダクタンス
                Dictionary<HumanBody.Nodes, double> dbTempNext = new Dictionary<HumanBody.Nodes, double>();  //乾球温度
                Dictionary<HumanBody.Nodes, double> mrTempNext = new Dictionary<HumanBody.Nodes, double>(); //平均放射温度
                Dictionary<HumanBody.Nodes, double> velsNext = new Dictionary<HumanBody.Nodes, double>();   //気流速度
                Dictionary<HumanBody.Nodes, double> rHumidNext = new Dictionary<HumanBody.Nodes, double>(); //相対湿度
                Dictionary<HumanBody.Nodes, double> matTempNext = new Dictionary<HumanBody.Nodes, double>();//物体温度
                Dictionary<HumanBody.Nodes, double> conRateNext = new Dictionary<HumanBody.Nodes, double>();//接触割合
                Dictionary<HumanBody.Nodes, double> conductNext = new Dictionary<HumanBody.Nodes, double>();//接触部の熱コンダクタンス

                //Read boundary data at time 0
                readData(sReader.ReadLine(), ref time, ref dbTemp, ref mrTemp, ref vels, ref rHumid, ref matTemp, ref conRate, ref conduct);
                readData(sReader.ReadLine(), ref nextTime, ref dbTempNext, ref mrTempNext, ref velsNext, ref rHumidNext, ref matTempNext, ref conRateNext, ref conductNext);

                while (true)
                {
                    if (nextTime < cTime)
                    {
                        string line = sReader.ReadLine();
                        if (line == null) break;
                        if (line.Split(',')[0] == "") break;
                        time = nextTime;
                        Dictionary<HumanBody.Nodes, double> buff;
                        buff = dbTemp; dbTemp = dbTempNext; dbTempNext = buff;
                        buff = mrTemp; mrTemp = mrTempNext; mrTempNext = buff;
                        buff = rHumid; rHumid = rHumidNext; rHumidNext = buff;
                        buff = vels; vels = velsNext; velsNext = buff;
                        buff = matTemp; matTemp = matTempNext; matTempNext = buff;
                        buff = conRate; conRate = conRateNext; conRateNext = buff;
                        buff = conduct; conduct = conductNext; conductNext = buff;
                        readData(line, ref nextTime, ref dbTempNext, ref mrTempNext, ref velsNext, ref rHumidNext, ref matTempNext, ref conRateNext, ref conductNext);
                    }
                    else
                    {
                        //Set boundary conditions
                        foreach (HumanBody.Nodes key in dbTemp.Keys)
                        {
                            body.SetDrybulbTemperature(key, interpolate(time, nextTime, dbTemp[key], dbTempNext[key], cTime));
                            body.SetMeanRadiantTemperature(key, interpolate(time, nextTime, mrTemp[key], mrTempNext[key], cTime));
                            body.SetVelocity(key, interpolate(time, nextTime, vels[key], velsNext[key], cTime));
                            body.SetRelativeHumidity(key, interpolate(time, nextTime, rHumid[key], rHumidNext[key], cTime));
                            body.SetMaterialTemperature(key, interpolate(time, nextTime, matTemp[key], matTempNext[key], cTime));
                            body.SetContactPortionRate(key, interpolate(time, nextTime, conRate[key], conRateNext[key], cTime));
                            body.SetHeatConductanceToMaterial(key, interpolate(time, nextTime, conduct[key], conductNext[key], cTime));
                        }

                        //Update Human body
                        body.Update(oSpan);

                        //Update current time
                        cTime += oSpan;

                        //Output informations to file
                        outputData(sWriter, body, cTime, false);

                        //Output informations to console
                        Console.WriteLine(cTime + " sec");
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>人体モデル計算の例</summary>
        private static void humanBodyTest()
        {
            //標準体躯の場合は引数不要
            //HumanBody body = new HumanBody();

            //人体モデルを作成:体重70kg,身長1.6m,年齢35歳,女性,心係数2.58,体脂肪率20%
            HumanBody body = new HumanBody(70, 1.6, 35, false, 2.58, 20);

            //着衣量[clo]を設定
            body.SetClothingIndex(0);
            //乾球温度[C]を設定
            body.SetDrybulbTemperature(42);
            //放射温度[C]を設定
            body.SetMeanRadiantTemperature(42);
            //気流速度[m/s]を設定
            body.SetVelocity(1.0);
            //相対湿度[%]を設定
            body.SetRelativeHumidity(50);

            //特定の部位の条件のみを設定したい場合(右手先のみ乾球温度20Cとした)
            body.SetDrybulbTemperature(HumanBody.Nodes.RightHand, 20);

            //時間を経過させ、状態を書き出す
            Console.WriteLine("時刻  |  右肩コア温度  |  右肩皮膚温度  |  左肩コア温度  |  左肩皮膚温度");
            for (int i = 0; i < 15; i++)
            {
                body.Update(120);
                ImmutableBodyPart rightShoulder = body.GetBodyPart(HumanBody.Nodes.RightShoulder);
                ImmutableBodyPart leftShoulder = body.GetBodyPart(HumanBody.Nodes.LeftShoulder);
                Console.Write(((i + 1) * 120) + "sec | ");
                Console.Write(rightShoulder.GetTemperature(BodyPart.Segments.Core).ToString("F2") + " | ");
                Console.Write(rightShoulder.GetTemperature(BodyPart.Segments.Skin).ToString("F2") + " | ");
                Console.Write(leftShoulder.GetTemperature(BodyPart.Segments.Core).ToString("F2") + " | ");
                Console.Write(leftShoulder.GetTemperature(BodyPart.Segments.Skin).ToString("F2") + " | ");
                Console.WriteLine();
            }

            Console.Read();
        }
Exemple #3
0
        /// <summary>Sample program calculating human body</summary>
        private static void humanBodyTest()
        {
            //This is constructor to make standard human body.
            //HumanBody body = new HumanBody();

            //Make human body model : Weight 70kg, Height 1.6m, Age 35, Female, Cardiac index 2.58, Fat 20%
            HumanBody body = new HumanBody(70, 1.6, 35, false, 2.58, 20);

            //Set clothing index [clo]
            body.SetClothingIndex(0);
            //Set dry-bulb temperature [C]
            body.SetDrybulbTemperature(42);
            //Set mean radiant temperature [C]
            body.SetMeanRadiantTemperature(42);
            //Set velocity [m/s]
            body.SetVelocity(1.0);
            //Set relative humidity [%]
            body.SetRelativeHumidity(50);

            //Use Nodes enumarator to set bouncary condition to particular position
            body.SetDrybulbTemperature(HumanBody.Nodes.RightHand, 20);

            //Updating body state
            Console.WriteLine("Time     |  R.Shoulder C temp  |  R.Shoulder S temp  |  L.Shoulder C temp  |  L.Shoulder S temp");
            for (int i = 0; i < 15; i++)
            {
                body.Update(120);
                ImmutableBodyPart rightShoulder = body.GetBodyPart(HumanBody.Nodes.RightShoulder);
                ImmutableBodyPart leftShoulder = body.GetBodyPart(HumanBody.Nodes.LeftShoulder);
                Console.Write(((i + 1) * 120) + "sec | ");
                Console.Write(rightShoulder.GetTemperature(BodyPart.Segments.Core).ToString("F2") + " | ");
                Console.Write(rightShoulder.GetTemperature(BodyPart.Segments.Skin).ToString("F2") + " | ");
                Console.Write(leftShoulder.GetTemperature(BodyPart.Segments.Core).ToString("F2") + " | ");
                Console.Write(leftShoulder.GetTemperature(BodyPart.Segments.Skin).ToString("F2") + " | ");
                Console.WriteLine();
            }

            Console.Read();
        }