package com.njcn.advance.utils.assess;

/**
 * Description:
 * Date: 2025/05/30  下午 3:35【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
public class ThreePhaseUnbalanceUtil {

    // Calculate three-phase voltage unbalance
    /** 
    * @Description: calculateVoltageUnbalance
    * @Param: 

     * @param pccShortCircuitCapacity 评估用户参数表最小短路容量
     * @param contractCapacity 评估用户参数表供电设备容量
     *
     * @param voltageLevel 评估用户参数表母线电压等级
     * @param isSinglePhase 评估用户参数表是否为单相负荷
     * @param negativeSequenceCurrent 负序电流值，导入背景数据时导入
     * @param ppcThreeVoltage PCC点背景三相电压不平衡，导入背景数据时导入
     * @param isStrict 是否严格估算
    * @return: double 
    * @Author: clam
    * @Date: 2025/06/06 
    */ 
    public static double calculateVoltageUnbalance(
             double pccShortCircuitCapacity,
            double contractCapacity,double voltageLevel,boolean isSinglePhase,
            double negativeSequenceCurrent,double ppcThreeVoltage,Boolean isStrict) {
        double threeVoltage;
        if (isSinglePhase) {
            // For single-phase load
            threeVoltage = contractCapacity* 100 / pccShortCircuitCapacity ;
        } else {
            // For three-phase load
            threeVoltage =  (Math.sqrt(3) * negativeSequenceCurrent * voltageLevel) * 100/ pccShortCircuitCapacity ;
        }
        if(isStrict){
            return threeVoltage+ppcThreeVoltage;
        }else{
            return Math.sqrt(threeVoltage*threeVoltage+ppcThreeVoltage*ppcThreeVoltage);
        }
    }

   
    // Get voltage unbalance limit
    public static double getVoltageUnbalanceLimit() {
        return 2.0; // Standard limit is 2%
    }
}
