⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cyme2psat

📁 电力系统分析计算程序
💻
📖 第 1 页 / 共 2 页
字号:
	} elsif ($data[0] eq "02") {	    $header = 2;	    @data = split ',' , $_;	    $busidx[$nbus] = $data[1];	    $busname[$nbus] = $data[2];	    $kzo[$nbus] = $data[3];	    $kvb[$nbus] = $data[5];	    $kvbase{$busidx[$nbus]} = $kvb[$nbus];	    $pload[$nbus] = $data[10]/$pbas;	    $qload[$nbus] = $data[11]/$pbas;	    $shur[$nbus] = $data[12];	    $shux[$nbus] = $data[13];	    $busvol[$nbus] = $data[11]/$kvb[$nbus];	    $bustype = $data[4];	    $busang[$nbus] = 3.14159265358979*assign($_,71,77,1)/180;	    if ($bustype == 1) {		$nsw++;		$swidx[$nsw] = $nbus;	    } elsif ($bustype == 2) {		$npv++;		$pvidx[$npv] = $nbus;	    }	    if ($shur[$nbus] != 0 || $shux[$nbus] != 0) {		$nsh++;		$shidx[$nsh] = $nbus;	    }  	    	    if ($pload[$nbus] != 0 || $qload[$nbus] != 0) {		$npq++;		$pqidx[$npq] = $nbus;	    }    	} elsif ($data[0] eq "03") {	    $header = 3;	    $nline++;	    $busfr[$nline] = $data[1];	    $bustt[$nline] = $data[2];	    $rest[$nline] = $data[4];	    $reat[$nline] = $data[5];	    $susc[$nline] = $data[6]; 	    if ($ovld == 0) {		$rateA[$nline] = $data[7]*		    $kvbase{$busfr[$nline]}*sqrt(3)/$pbas;		$rateS[$nline] = 0;			    } else {		$rateA[$nline] = 0;				$rateS[$nline] = $data[7]/$pbas;			    }	    $tap[$nline] = evaltap($data[8],$data[9],				   $kvbase{$busfr[$nline]},				   $kvbase{$bustt[$nline]});	    $phs[$nline] = evalphs($data[10]);	} elsif ($data[0] eq "04") {	    $header = 4;	    # rectifier data	    $nhvdc++;	    $rbus[$nhvdc] = $data[1];	    $rnum[$nhvdc] = $data[2];	    $rKV[$nhvdc] = $data[3];	    $alpha[$nhvdc] = $data[4];	    $rdc[$nhvdc] = $data[5];	} elsif ($data[0] eq "00") {	    if ($header == 1) {		# nothing to do for now...	    } elsif ($header == 2) {		$pgen[$nbus] = $data[1]/$pbas;		$qmi[$nbus] = $data[2]/$pbas;		$qma[$nbus] = $data[3]/$pbas;	    } elsif ($header == 3) {		# nothing to do for now...	    } elsif ($header == 4) {		# inverter data		$ibus[$nhvdc] = $data[1];		$inum[$nhvdc] = $data[2];		$iKV[$nhvdc] = $data[3];		$gamma[$nhvdc] = $data[4];		$pdes[$nhvdc] = $data[5];		$vdes[$nhvdc] = $data[6];	    }	}	    }}# -----------------------------------------------------------------------# close data file# -----------------------------------------------------------------------close(IN) || die "cannot close $ARGV[0]: $!\n";# -----------------------------------------------------------------------# open output data file# -----------------------------------------------------------------------print "Writing PSAT file \"$ARGV[1]\"...\n";carret();open(OUT,">$ARGV[1]") || die "cannot open $ARGV[1]: $!\n";# -----------------------------------------------------------------------# write output data file# -----------------------------------------------------------------------print OUT "% File generated by PSAT from CYME data file.\n";print OUT "% "."-" x 78 . "\n";print OUT "% Author:   Federico Milano\n";print OUT "% E-mail:   Federico.Milano\@uclm.es\n";print OUT "% "."-" x 78 . "\n";print OUT "% Generic CYMEFLOW data format "."$ARGV[0]"."\n";for ($i = 0; $i <= $ntitle; $i++) { print OUT "% $title[$i]\n"; }# -----------------------------------------------------------------------# write Bus.con# -----------------------------------------------------------------------if ($nbus >= 0) {    $format = "%4d  %6.2f  1   0   1  %2d;\n";    print OUT "Bus.con = [ ...\n";    for ($i = 0; $i <= $nbus; $i++) {	printf OUT $format,$busidx[$i],$kvb[$i],$kzo[$i];    }    print OUT "   ];\n\n";}# -----------------------------------------------------------------------# write SW.con# -----------------------------------------------------------------------if ($nsw >= 0) {    printf OUT "SW.con = [ ...\n";    $format = "%4d 100 %6.2f 1 0 %8.5f %8.5F 1.1 0.9 %8.5f 1];\n\n";    $h = $swidx[0];    printf OUT $format,$busidx[$h],$kvb[$h],$qma[$h],$qmi[$h],$pgen[$h];}# -----------------------------------------------------------------------# write PV.con# -----------------------------------------------------------------------if ($npv >= 0) {    printf OUT "PV.con = [ ...\n";    $format = "%4d 100 %6.2f %8.5f 1 %8.5f %8.5f 1.1 0.9 1;\n";    for ($i = 0; $i <= $npv; $i++) {	$h = $pvidx[$i];	printf OUT $format,$busidx[$h],$kvb[$h],$pgen[$h],$qma[$h],$qmi[$h];    }    printf OUT "   ];\n\n";}# -----------------------------------------------------------------------# write PQ.con# -----------------------------------------------------------------------if ($npq >= 0) {    printf OUT "PQ.con = [ ...\n";    $format = "%4d 100 %6.2f %8.5f %8.5f 1.1 0.9 1;\n";    for ($i = 0; $i <= $npq; $i++) {	$h = $pqidx[$i];	printf OUT $format,$busidx[$h],$kvb[$h],$pload[$h],$qload[$h];    }    printf OUT "   ];\n\n";}# -----------------------------------------------------------------------# write Shunt.con# -----------------------------------------------------------------------if ($nsh >= 0) {    printf OUT "Shunt.con = [ ...\n";    $format = "%4d 100 %6.2f 60 %8.5f %8.5f;\n";    for ($i = 0; $i <= $nsh; $i++) {	$h = $shidx[$i];	printf OUT $format,$busidx[$h],$kvb[$h],$shur[$h],$shux[$h];    }    printf OUT "   ];\n\n";}# -----------------------------------------------------------------------# write Line.con# -----------------------------------------------------------------------if ($nline >= 0) {    print OUT "Line.con = [ ...\n";    $format = "%4d %4d 100 %6.2f 60 0 %8.4f " . 	"%8.5f " x 5 . "%8.3f 0 %8.3f;\n";    for ($i = 0; $i <= $nline; $i++) {	$k = $kvbase{$busfr[$i]}/$kvbase{$bustt[$i]};	if ($k == 1) { $k = 0; }	printf OUT $format,$busfr[$i],$bustt[$i],	$kvbase{$busfr[$i]},$k,$rest[$i],$reat[$i],$susc[$i],	$tap[$i],$phs[$i],$rateA[$i],$rateS[$i];    }    printf OUT "   ];\n\n";}    # -----------------------------------------------------------------------# write Area.con# -----------------------------------------------------------------------if ($narea >= 0) {    printf OUT "Area.con = [ ...\n";    $format = "%4d %4d 100 %8.5f %8.5f;\n";        for ($i = 0; $i <= $narea; $i++) {	printf OUT $format,$areanum[$i],$busidx[$swidx[0]],	$areaexp[$i],$areatol[$i];    }    printf OUT "   ];\n\n";}# -----------------------------------------------------------------------# write bus names# -----------------------------------------------------------------------$nbus >= 0 && print OUT "Bus.names = { ...\n";$h = ($nbus+1) % 5;if ($h == 0) {$h = 5;}if (($nbus+1) > 5) {    for ($i = 0; $i <= $nbus-$h; $i+=5) {	print OUT "  '$busname[$i]'; '$busname[$i+1]'; " . 	    "'$busname[$i+2]'; '$busname[$i+3]'; '$busname[$i+4]';\n";    }}print OUT "  ";for ($i = $nbus-$h+1; $i <= $nbus-1; $i++) {    print OUT "'$busname[$i]'; ";}print OUT "'$busname[$nbus]'};\n\n";# -----------------------------------------------------------------------# close output data file# -----------------------------------------------------------------------close(OUT) || die "cannot close $ARGV[1]: $!\n";print "Conversion completed.\n";# -----------------------------------------------------------------------# function for formatting data and/or assigning default values# -----------------------------------------------------------------------sub assign {    my $param;    $param = substr($_[0],$_[1]-1,$_[2]-$_[1]+1);    $param =~ s/\s*//g;    unless ($param) {$param = "0";}    unless ($param =~ /[1-9]/) {$param = $_[3];}    return $param;}# -----------------------------------------------------------------------# function for writing a separator# -----------------------------------------------------------------------sub carret { $verbose && print "-" x 50 . "\n"; }# -----------------------------------------------------------------------# function for determing the transformer tap ratio# -----------------------------------------------------------------------sub evaltap {    if (!$_[0]) {$_[0] = $_[2];}     if (!$_[1]) {$_[1] = $_[3];}     return (($_[0]/$_[2])/($_[1]/$_[3]));}# -----------------------------------------------------------------------# function for determing the transformer phase shifter# -----------------------------------------------------------------------sub evalphs {    if (!$_[0]) {$_[0] = 0;}     return $_[0];}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -