Beispiel #1
0
        Dictionary <ViewFactorCoordinate, float> FindInconsistencies(Dictionary <ViewFactorCoordinate, float> toCheck)
        {
            Dictionary <ViewFactorCoordinate, float> Results = new Dictionary <ViewFactorCoordinate, float>();

            foreach (KeyValuePair <ViewFactorCoordinate, float> p in toCheck)
            {
                // If zero value, check reciprocal
                if (p.Value == 0)
                {
                    ViewFactorCoordinate CRec = p.Key.Swap();
                    if (toCheck.TryGetValue(CRec, out float VFRec))
                    {
                        SatComponent Source = Model.Components.Find(x => string.Compare(x.Name, p.Key.SourceName, true) == 0);
                        SatComponent Target = Model.Components.Find(x => string.Compare(x.Name, p.Key.TargetName, true) == 0);

                        if (Source != null && Target != null)
                        {
                            float AreaSource = Source.GetBBoxTotalArea();
                            float AreaTarget = Target.GetBBoxTotalArea();

                            try
                            {
                                VFRec = AreaTarget / AreaSource * VFRec;
                                if (Settings.f_Verbose)
                                {
                                    Console.WriteLine("\tChanging VF from " + p.Value.ToString("F4", Settings.Format) + " to " + VFRec.ToString("F4", Settings.Format));
                                }
                            }
                            catch
                            {
                                VFRec = p.Value;
                            }
                        }
                    }
                    Results.Add(p.Key, VFRec);
                }
                else
                {
                    Results.Add(p.Key, p.Value);
                }
            }
            return(Results);
        }
Beispiel #2
0
        void WriteMatrixToFile(Dictionary <ViewFactorCoordinate, float> results)
        {
            using (StreamWriter sw = new StreamWriter("matrix.txt"))
            {
                // Write header
                sw.WriteLine("% View factor matrix generated on " + DateTime.Now.ToLongDateString());
                sw.WriteLine("% One row per source, e.g. row n: n -> target");
                // Write list of components
                int i = 1;
                foreach (SatComponent sc in Model.Components)
                {
                    sw.WriteLine("% Row / column " + i++ + ": " + sc.Name);
                }
                // Write matrix
                foreach (SatComponent source in Model.Components)
                {
                    float LineSum = 0;
                    foreach (SatComponent target in Model.Components)
                    {
                        if (source == target)
                        {
                            sw.Write("0");
                        }
                        else
                        {
                            ViewFactorCoordinate C = new ViewFactorCoordinate(source.Name, target.Name);
                            if (results.TryGetValue(C, out float Factor))
                            {
                                sw.Write(Factor.ToString("F4", Settings.Format));
                                LineSum += Factor;
                            }
                        }
                        sw.Write("\t");
                    }
                    sw.Write("\n");

                    Console.WriteLine("Component <" + source.Name + "> radiates <" + LineSum.ToString("F3", Settings.Format) + ">.");
                }
                sw.Close();
            }
        }
Beispiel #3
0
        Dictionary <ViewFactorCoordinate, float> ComputeVFMatrix(List <ViewFactorPerFace> vfList)
        {
            Dictionary <ViewFactorCoordinate, float> Results = new Dictionary <ViewFactorCoordinate, float>();

            foreach (ViewFactorPerFace vf in vfList)
            {
                // Get coordinate, swap source and target
                string SourceName      = vf.Coordinate.SourceName;
                string TargetName      = vf.Coordinate.TargetName;
                ViewFactorCoordinate C = new ViewFactorCoordinate(SourceName, TargetName);
                // Check if already in dictionary
                if (Results.ContainsKey(C))
                {
                    Results[C] += vf.Factor;
                }
                // New entry
                else
                {
                    Results.Add(C, vf.Factor);
                }
            }
            return(Results);
        }
Beispiel #4
0
 public ViewFactorPerFace(string sourceName, string targetName, AAFace sourceFace, float factor)
 {
     Coordinate = new ViewFactorCoordinate(sourceName, targetName);
     Factor     = factor;
     SourceFace = sourceFace;
 }