Esempio n. 1
0
        private trans_calc_result_winding CalculateSecondary(double w1_R)
        {
            double Vout = _input.common.Vout;

            trans_calc_result_winding w2 = calculateWinding(_input.common, _input.secondary);

            double Vout_idle = Vout;
            double Vout_load = 0;

            if (_result.turns_ratio < 0.000001)
            {
                throw new Exception("Turns ratio hasn't been calculated");
            }

            double total_R = w1_R / _result.turns_ratio / _result.turns_ratio + w2.resistance;

            if (_input.common.Iout_max > 0.0000000001)
            {
                double regulation_vdrop = _input.common.Iout_max * total_R;
                if (regulation_vdrop > Vout_idle / 2)
                {
                    throw new Exception($"Voltage drop too high: {regulation_vdrop}. Check Iout, Vout, wire ga");
                }

                Vout_load = Vout_idle - regulation_vdrop;

                _result.Iout_max   = _input.common.Iout_max;
                _result.power_VA   = _result.Iout_max * Vout_load;
                _result.regulation = (Vout_idle - Vout_load) / Vout_idle * 100;
            }

            _result.Vout_idle  = Vout_idle;
            _result.Vout_load  = Vout_load;
            _result.total_eq_R = total_R;
            return(w2);
        }
Esempio n. 2
0
        private trans_calc_result_winding calculateWinding(trans_calc_input_common common, trans_calc_input_winding w)
        {
            double dl = w.awg.Diameter_m / w.w_factor;
            double dh = w.awg.Diameter_m / w.w_factor;

            trans_calc_result_winding res = new trans_calc_result_winding();

            if (w.N_per_layer == 0)
            {
                w.N_per_layer = (int)(common.Core_L / dl);
                if (w.N_per_layer > w.N)
                {
                    w.N_per_layer = w.N;
                }
            }

            if (w.N_per_layer == 0)
            {
                throw new Exception("Error: turns per layer calculated to zero");
            }

            int totalLayers = (int)(w.N / (double)w.N_per_layer);

            int lastTurns = (int)w.N - (totalLayers * w.N_per_layer);

            if (lastTurns == 0)
            {
                lastTurns = (int)w.N_per_layer;
            }
            else
            {
                ++totalLayers;
            }

            double length_m           = 0;
            double turnsPerLayerSaved = w.N_per_layer;

            for (int i = 0; i < totalLayers; ++i)
            {
                double delta = dh * (double)i;
                if (i == totalLayers - 1)
                {
                    turnsPerLayerSaved = lastTurns;
                }

                double p = 2.0 * (common.Core_W + common.Core_H + 2.0 * delta);
                length_m += p * turnsPerLayerSaved;
            }

            double length_f   = length_m / AWG.meters_in_foot;
            double thickness  = totalLayers * dh;
            double resistance = w.awg.CalculateResistance(length_m, common.max_temp);
            double mass       = w.awg.CalculateMass_g(length_m);

            res.length_m       = length_m;
            res.length_ft      = length_f;
            res.thickness_mm   = thickness * 1000;
            res.resistance     = resistance;
            res.mass           = mass;
            res.totalLayers    = totalLayers;
            res.N              = w.N;
            res.N_per_layer    = (int)w.N_per_layer;
            res.lastLayerTurns = (lastTurns == (int)w.N_per_layer) ? 0 : lastTurns;

            if (w.ampacity_mil_per_amp != 0)
            {
                res.awg_max_current_amp = w.awg.GetCircularMils() / w.ampacity_mil_per_amp;
            }

            res.awg = w.awg;

            return(res);
        }
Esempio n. 3
0
        public trans_calc_result_text Calculate(trans_calc_input_text text_input)
        {
            _input.ConvertTextToInput(text_input);


            double L1;
            double Ae;

            CalculateCommon(out L1, out Ae);

            // Calculate primary
            bool retry_primary = false;
            int  minAWG        = 8;

            if (_input.primary.awg == null)
            {
                retry_primary = true;
            }

            if (_input.processSecondary)
            {
                CalculateTurnsRatio();
                CalculatePrimaryCurrent();
            }

            do
            {
                if (retry_primary)
                {
                    _input.primary.awg = AutoSelectAWG(minAWG++, _input.isMinimizeRegulation, _input.primary, _result.Ip_full_load);
                }

                trans_calc_result_winding w1 = calculateWinding(_input.common, _input.primary);

                w1.L            = L1;
                _result.primary = w1;

                //Calculate secondary if configured
                if (_input.processSecondary)
                {
                    _result.Iout_max      = _input.common.Iout_max;
                    _input.common.Core_H += w1.thickness_mm / 1000;
                    _input.common.Core_W += w1.thickness_mm / 1000;

                    bool retry_secondary = false;
                    minAWG = 8;
                    if (_input.secondary.awg == null)
                    {
                        retry_secondary = true;
                    }

                    trans_calc_result_winding w2 = null;
                    do
                    {
                        if (retry_secondary)
                        {
                            _input.secondary.awg = AutoSelectAWG(minAWG++, _input.isMinimizeRegulation, _input.secondary, _input.common.Iout_max);
                        }

                        w2 = CalculateSecondaryWithRetries(w1.resistance);

                        if (retry_secondary &&
                            (_input.common.WindowSize < 0.000000001 ||
                             w1.thickness_mm + _input.common.InsulationThickness + w2.thickness_mm
                             <= _input.common.WindowSize))
                        {
                            retry_secondary = false;
                            retry_primary   = false;
                        }
                    } while (retry_secondary);

                    if (_result.permeability > 0.00000000001 && _result.mpath_l_m > 0.0000001)
                    {
                        w2.L = w2.N * w2.N * _result.permeability * u0 * Ae / _result.mpath_l_m;
                    }

                    _result.secondary          = w2;
                    _result.total_thickness_mm =
                        w1.thickness_mm + _input.common.InsulationThickness + w2.thickness_mm;
                    _result.wire_total_weight = w1.mass + w2.mass;
                    _result.wire_csa_ratio    = w1.awg.Csa_m2 / w2.awg.Csa_m2;
                    _result.wire_weight_ratio = w1.mass / w2.mass;
                }
            }while (retry_primary);

            ConvertUnits();

            return(new trans_calc_result_text(_result, _input));
        }