Example #1
0
        public TransCalc()
        {
            awgValues.AddRange(new AWG[] {
                new AWG(35, 0.14224),
                new AWG(34, 0.16002),
                new AWG(33, 0.18034),
                new AWG(32, 0.2032),
                new AWG(31, 0.22606),
                new AWG(30, 0.254),
                new AWG(29, 0.28702),
                new AWG(28, 0.32004),
                new AWG(27, 0.36068),
                new AWG(26, 0.40386),
                new AWG(25, 0.45466),
                new AWG(24, 0.51054),
                new AWG(23, 0.57404),
                new AWG(22, 0.64516),
                new AWG(21, 0.7239),
                new AWG(20, 0.8128),
                new AWG(19, 0.91186),
                new AWG(18, 1.02362),
                new AWG(17, 1.15062),
                new AWG(16, 1.29032),
                new AWG(15, 1.45034),
                new AWG(14, 1.62814),
                new AWG(13, 1.8288),
                new AWG(12, 2.05232),
                new AWG(11, 2.30378),
                new AWG(10, 2.58826),
                new AWG(9, 2.90576),
                new AWG(8, 3.2639)
            });

            _input           = new TransCalcInput(this);
            _filePersistence = new FilePersistence(this);
        }
Example #2
0
        public void SaveResults(trans_calc_input_text strin, trans_calc_result_text result, string fileName)
        {
            TransCalcInput input = new TransCalcInput(tc);

            input.ConvertTextToInput(strin);

            using (StreamWriter sw = new StreamWriter(fileName))
            {
                sw.WriteLine("Input:\n");

                sw.WriteLine($"Core size  WxHxL     : {strin.core_W} x {strin.core_H} x {strin.core_L} cm");
                sw.WriteLine($"Ae, WxH              : {strin.Ae_W} x {strin.Ae_H} cm");
                if (strin.window_size != "")
                {
                    sw.WriteLine($"Window size          : {strin.window_size} mm");
                }
                if (input.common.mpath_l_cm > 0.0000001)
                {
                    sw.WriteLine($"Mpath, WxH           : {strin.mpath_W} x {strin.mpath_H} cm");
                }
                if (strin.Bmax != "")
                {
                    sw.WriteLine($"Bmax                 : {strin.Bmax} T");
                }
                if (strin.H != "")
                {
                    sw.WriteLine($"H                    : {strin.H} " + tc.HUnitlsLabel);
                }
                if (strin.permeability != "")
                {
                    sw.WriteLine($"u/u0                 : {strin.permeability}");
                }
                if (strin.I_ex != "")
                {
                    sw.WriteLine($"Iex                  : {strin.I_ex} A");
                }

                sw.WriteLine($"L1/L2 coupling coeff : {strin.coupling_coeff}");
                sw.WriteLine($"Stacking factor      : {strin.stackingFactor}");
                if (strin.insulationThickness != "")
                {
                    sw.WriteLine($"Insulation           : {strin.insulationThickness} mm");
                }
                if (strin.Vout != "")
                {
                    string fullLoad = strin.isVoutAtFullLoad ? "(full load)" : "(idle)";
                    sw.WriteLine($"Vout                 : {strin.Vout} {fullLoad}");
                }
                if (strin.Iout_max != "")
                {
                    sw.WriteLine($"Iout max             : {strin.Iout_max} A");
                }
                sw.WriteLine($"Max temperature      : {strin.maxTemp} " + tc.TempUnitsLabel);
                if (strin.max_eq_R != "")
                {
                    sw.WriteLine($"Max equivalent R     : {strin.max_eq_R}");
                }
                sw.WriteLine();

                sw.WriteLine($"Primary   : {strin.awg1} AWG, Wfactor: {strin.wfactor1}, N: {strin.N1}, " +
                             $"N per layer: {strin.N_per_layer1} C.M. per amp: {strin.ampacity1}");

                if (input.processSecondary)
                {
                    sw.WriteLine($"Secondary : {strin.awg2} AWG, Wfactor: {strin.wfactor2}, N: {strin.N2}, " +
                                 $"N per layer: {strin.N_per_layer2} C.M. per amp: {strin.ampacity2}");
                }

                sw.WriteLine($"\nMains: {input.common.Vin.ToString()}V / {input.common.Freq.ToString()}Hz");

                sw.WriteLine("\n=== Results: =====================================\n");
                sw.WriteLine("Primary:\n");
                sw.WriteLine($"AWG                  : {result.AWG1}");
                sw.WriteLine($"Turns                : {result.N_1}");
                sw.WriteLine($"Turns per layer      : {result.N_per_layer_1}");
                sw.WriteLine($"Total layers         : {result.totalLayers_1}");
                sw.WriteLine($"Last layer turns     : {result.lastLayerTurns_1}");
                sw.WriteLine($"Wire length          : {result.length_m_1} m / {result.length_ft_1} ft");
                sw.WriteLine($"Build-up             : {result.buildup_mm_1} mm");
                sw.WriteLine($"R                    : {result.R_1}");
                if (result.mpath_l_m != Constants.EmptyValue)
                {
                    sw.WriteLine($"Magnetic path        : {result.mpath_l_m} m");
                }
                if (result.L_1 != Constants.EmptyValue)
                {
                    sw.WriteLine($"L                    : {result.L_1} H");
                }
                sw.WriteLine($"Bmax                 : {result.B_max} T");
                if (result.permeability != Constants.EmptyValue)
                {
                    sw.WriteLine($"u/u0                 : {result.permeability}");
                }
                if (result.H != Constants.EmptyValue)
                {
                    sw.WriteLine($"H                    : {result.H} " + tc.HUnitlsLabel);
                }
                if (result.I_ex != Constants.EmptyValue)
                {
                    sw.WriteLine($"Iex                  : {result.I_ex} A");
                }
                if (result.Ip_full_load != Constants.EmptyValue)
                {
                    sw.WriteLine($"Ip, full load        : {result.Ip_full_load} A");
                }
                if (result.awg_max_current_amp_1 != Constants.EmptyValue)
                {
                    sw.WriteLine($"AWG max current      : {result.awg_max_current_amp_1} A");
                }
                sw.WriteLine($"Weight               : {result.weight_1} " + tc.MassUnitsLabel);

                if (input.processSecondary)
                {
                    sw.WriteLine("\nSecondary:\n");
                    sw.WriteLine($"AWG                  : {result.AWG2}");
                    sw.WriteLine($"Turns                : {result.N_2}");
                    sw.WriteLine($"Turns per layer      : {result.N_per_layer_2}");
                    sw.WriteLine($"Total layers         : {result.totalLayers_2}");
                    sw.WriteLine($"Last layer turns     : {result.lastLayerTurns_2}");
                    sw.WriteLine($"Wire length          : {result.length_m_2} m / {result.length_ft_2} ft");
                    sw.WriteLine($"Build-up             : {result.buildup_mm_2} mm");
                    sw.WriteLine($"R                    : {result.R_2}");
                    sw.WriteLine($"Total build-up       : {result.total_thickness_mm} mm");
                    sw.WriteLine($"L                    : {result.L_2} H");
                    sw.WriteLine($"Vout idle            : {result.Vout_idle} V");
                    sw.WriteLine($"Vout full load       : {result.Vout_load} V");
                    sw.WriteLine($"Iout full load       : {result.Iout_max} A");
                    sw.WriteLine($"AWG max current      : {result.awg_max_current_amp_2} A");
                    sw.WriteLine($"Weight               : {result.weight_2} " + tc.MassUnitsLabel);

                    sw.WriteLine($"\nTurns ratio          : {result.turns_ratio}");
                    sw.WriteLine($"Wire c.s.a ratio     : {result.wire_csa_ratio}");
                    sw.WriteLine($"Total weight         : {result.wire_total_weight} " + tc.MassUnitsLabel);
                    sw.WriteLine($"Weight ratio         : {result.wire_weight_ratio}");
                    sw.WriteLine($"Output Power         : {result.power_VA} VA");
                    sw.WriteLine($"Total equivalent R   : {result.total_eq_R}");
                    sw.WriteLine($"% Regulation         : {result.regulation}");
                }
                if (result.warnings.Count > 0)
                {
                    sw.WriteLine("\nWarnings:\n");
                    foreach (string msg in result.warnings)
                    {
                        sw.WriteLine(msg);
                    }
                }
            }
        }
Example #3
0
        public trans_calc_result_text(trans_calc_result res, TransCalcInput input)
        {
            this.warnings           = new List <string>();
            IsAmpacity1Exceeded     = false;
            IsAmpacity2Exceeded     = false;
            IsWindowExceeded        = false;
            IsMaxResistanceExceeded = false;

            if (input.processSecondary)
            {
                if (res.Ip_full_load > 0.00000001 &&
                    res.primary.awg_max_current_amp > 0.00000001 &&
                    res.Ip_full_load > res.primary.awg_max_current_amp)
                {
                    var Ip          = String.Format("{0:0.##}", res.Ip_full_load);
                    var maxAmpacity = String.Format("{0:0.##}", res.primary.awg_max_current_amp);
                    warnings.Add($"Ip={Ip}A exceeds the maximum ampacity of the primary={maxAmpacity}A");
                    IsAmpacity1Exceeded = true;
                }

                if (res.Iout_max > 0.00000001 &&
                    res.secondary.awg_max_current_amp > 0.0000001 &&
                    (1 - res.secondary.awg_max_current_amp / res.Iout_max) > 0.05)
                {
                    var Iout        = String.Format("{0:0.##}", res.Iout_max);
                    var maxAmpacity = String.Format("{0:0.##}", res.secondary.awg_max_current_amp);
                    warnings.Add($"Iout={Iout}A exceeds the maximum ampacity of the secondary={maxAmpacity}A");
                    IsAmpacity2Exceeded = true;
                }

                if (input.common.WindowSize > 0.0000001 &&
                    (1 - input.common.WindowSize / res.total_thickness_mm) > 0.05)
                {
                    var totalBuildup = String.Format("{0:0.#}", res.total_thickness_mm);
                    warnings.Add($"Total build-up: {totalBuildup}mm exceeds the maximum window size: {input.common.WindowSize}mm");
                    IsWindowExceeded = true;
                }

                if (input.common.max_res_R > 0.0000001 && res.total_eq_R > input.common.max_res_R)
                {
                    var total_eq_R = String.Format("{0:0.#}", res.total_eq_R);
                    warnings.Add($"Total R: {total_eq_R} exceeds the maximum total R: {input.common.max_res_R}");
                    IsMaxResistanceExceeded = true;
                }
            }

            this.length_m_1       = String.Format("{0:0.##}", res.primary.length_m);
            this.length_ft_1      = String.Format("{0:0.##}", res.primary.length_ft);
            this.buildup_mm_1     = String.Format("{0:0.##}", res.primary.thickness_mm);
            this.R_1              = String.Format("{0:0.##}", res.primary.resistance);
            this.N_1              = res.primary.N.ToString();
            this.N_per_layer_1    = res.primary.N_per_layer.ToString();
            this.totalLayers_1    = res.primary.totalLayers.ToString();
            this.lastLayerTurns_1 =
                (res.primary.lastLayerTurns != 0) ? res.primary.lastLayerTurns.ToString() : Constants.EmptyValue;
            this.mpath_l_m = (res.mpath_l_m > 0.0000001) ?
                             String.Format("{0:0.##}", res.mpath_l_m) : Constants.EmptyValue;
            this.awg_max_current_amp_1 =
                (res.primary.awg_max_current_amp > 0.0000001) ? String.Format("{0:0.##}", res.primary.awg_max_current_amp) : Constants.EmptyValue;
            this.L_1 =
                (res.primary.L > 0.0000001) ? String.Format("{0:0.##}", res.primary.L) : Constants.EmptyValue;

            this.B_max = String.Format("{0:0.##}", res.B_max);
            this.H     =
                (res.H > 0.0000001) ? String.Format("{0:0.##}", res.H) : Constants.EmptyValue;

            this.I_ex =
                (res.I_ex > 0.0000001) ? String.Format("{0:0.##}", res.I_ex) : Constants.EmptyValue;

            this.permeability =
                (res.permeability > 0.0000001) ? String.Format("{0:0.##}", res.permeability) : Constants.EmptyValue;

            this.weight_1 =
                (res.primary.mass > 0.0000001) ? String.Format("{0:0.##}", res.primary.mass) : Constants.EmptyValue;

            /////////////////////////////////
            if (input.processSecondary)
            {
                this.length_m_2       = String.Format("{0:0.##}", res.secondary.length_m);
                this.length_ft_2      = String.Format("{0:0.##}", res.secondary.length_ft);
                this.buildup_mm_2     = String.Format("{0:0.##}", res.secondary.thickness_mm);
                this.R_2              = String.Format("{0:0.##}", res.secondary.resistance);
                this.N_2              = res.secondary.N.ToString();
                this.N_per_layer_2    = res.secondary.N_per_layer.ToString();
                this.totalLayers_2    = res.secondary.totalLayers.ToString();
                this.lastLayerTurns_2 =
                    (res.secondary.lastLayerTurns != 0) ? res.secondary.lastLayerTurns.ToString() : "";

                this.awg_max_current_amp_2 =
                    (res.secondary.awg_max_current_amp > 0.0000001) ? String.Format("{0:0.##}", res.secondary.awg_max_current_amp) : Constants.EmptyValue;

                this.L_2 =
                    (res.secondary.L > 0.0000001) ? String.Format("{0:0.##}", res.secondary.L) : Constants.EmptyValue;

                this.weight_2 =
                    (res.secondary.mass > 0.0000001) ? String.Format("{0:0.##}", res.secondary.mass) : Constants.EmptyValue;

                this.total_thickness_mm =
                    (res.total_thickness_mm > 0.0000001) ? String.Format("{0:0.##}", res.total_thickness_mm) : Constants.EmptyValue;

                this.Vout_idle = String.Format("{0:0.##}", res.Vout_idle);
                this.Vout_load = (res.Vout_load > 0.0000001) ?
                                 String.Format("{0:0.##}", res.Vout_load) : Constants.EmptyValue;
                this.Iout_max =
                    (res.Iout_max > 0.0000001) ? String.Format("{0:0.##}", res.Iout_max) : Constants.EmptyValue;

                if (res.turns_ratio > 1)
                {
                    this.turns_ratio = String.Format("{0:0.##}", res.turns_ratio) + ":1";
                }
                else
                {
                    this.turns_ratio = "1:" + String.Format("{0:0.##}", 1 / res.turns_ratio);
                }
                if (res.wire_csa_ratio > 1)
                {
                    this.wire_csa_ratio = String.Format("{0:0.##}", res.wire_csa_ratio) + ":1";
                }
                else
                {
                    this.wire_csa_ratio = "1:" + String.Format("{0:0.##}", 1 / res.wire_csa_ratio);
                }
                this.wire_total_weight = String.Format("{0:0.##}", res.wire_total_weight);

                if (res.wire_weight_ratio > 1)
                {
                    this.wire_weight_ratio = String.Format("{0:0.##}", res.wire_weight_ratio) + ":1";
                }
                else
                {
                    this.wire_weight_ratio = "1:" + String.Format("{0:0.##}", 1 / res.wire_weight_ratio);
                }
                this.Ip_full_load = (res.Ip_full_load > 0.00000001) ?
                                    String.Format("{0:0.##}", res.Ip_full_load) : Constants.EmptyValue;
                this.power_VA = (res.power_VA > 0.0000000001) ?
                                String.Format("{0:0.##}", res.power_VA) : Constants.EmptyValue;

                this.regulation = (res.regulation > 0.0000000001) ?
                                  String.Format("{0:0.##}", res.regulation) : Constants.EmptyValue;

                this.total_eq_R = (res.total_eq_R > 0.0000000001) ?
                                  String.Format("{0:0.##}", res.total_eq_R) : Constants.EmptyValue;
                this.AWG1 = res.primary.awg.Gauge.ToString();
                this.AWG2 = res.secondary.awg.Gauge.ToString();
            }
            else
            {
                this.length_m_2            = Constants.EmptyValue;
                this.length_ft_2           = Constants.EmptyValue;
                this.buildup_mm_2          = Constants.EmptyValue;
                this.R_2                   = Constants.EmptyValue;
                this.N_2                   = Constants.EmptyValue;
                this.N_per_layer_2         = Constants.EmptyValue;
                this.totalLayers_2         = Constants.EmptyValue;
                this.lastLayerTurns_2      = Constants.EmptyValue;
                this.awg_max_current_amp_2 = Constants.EmptyValue;
                this.L_2                   = Constants.EmptyValue;
                this.weight_2              = Constants.EmptyValue;
                this.total_thickness_mm    = Constants.EmptyValue;
                this.Vout_idle             = Constants.EmptyValue;
                this.Vout_load             = Constants.EmptyValue;
                this.Iout_max              = Constants.EmptyValue;
                this.turns_ratio           = Constants.EmptyValue;
                this.wire_csa_ratio        = Constants.EmptyValue;
                this.wire_total_weight     = Constants.EmptyValue;
                this.wire_weight_ratio     = Constants.EmptyValue;
                this.Ip_full_load          = Constants.EmptyValue;
                this.power_VA              = Constants.EmptyValue;
                this.total_eq_R            = Constants.EmptyValue;
                this.regulation            = Constants.EmptyValue;
                this.AWG1                  = Constants.EmptyValue;
                this.AWG2                  = Constants.EmptyValue;
            }
        }