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

📄 ge2psat

📁 用于电力系统的一个很好的分析软件
💻
📖 第 1 页 / 共 2 页
字号:
    @data = mysplit($_);    # add area only if a slack bus is defined    $areanum[++$narea] = $data[0];    $areaname[$narea] = $data[1];    $areaname[$narea] =~ s/\'/\'\'/g;    $areaslack[$narea] = $data[2];    $areaexp[$narea] = $data[3]/$pbas;    $areatol[$narea] = $data[4]/$pbas;    $areapnet[$narea] = $data[5]/$pbas;    $areaqnet[$narea] = $data[6]/$pbas;}# read zone datawhile (<IN>) {    chomp;    if (/^interface data/) { last; }    @data = mysplit($_);    $zonenum[++$nzone] = $data[0];    $zonename[$nzone] = $data[1];    $zonename[$nzone] =~ s/\'/\'\'/g;    $zonepnet[$nzone] = $data[2]/$pbas;    $zoneqnet[$nzone] = $data[3]/$pbas;}# read interface datawhile (<IN>) {    chomp;    if (/^interface branch/) { last; }    @data = mysplit($_);}# read interfase branch datawhile (<IN>) {    chomp;    if (/^dc bus/) { last; }    @data = mysplit($_);}# read dc bus datawhile (<IN>) {    chomp;    if (/^dc converter/) { last; }    @data = mysplit($_);}# read dc converter datawhile (<IN>) {    chomp;    if (/^z/) { last; }    @data = mysplit($_);}# read z table datawhile (<IN>) {    chomp;    if (/^gcd/) { last; }    if (/^ped/) { last; }    @data = mysplit($_);}# read gcd or ped datawhile (<IN>) {    chomp;    if (/^transaction/) { last; }    @data = mysplit($_);}# read transaction datawhile (<IN>) {    chomp;    if (/^owner/) { last; }    @data = mysplit($_);}# read owner datawhile (<IN>) {    chomp;    if (/^motor/) { last; }    @data = mysplit($_);}# read motor datawhile (<IN>) {    chomp;    if (/^line/) { last; }    @data = mysplit($_);}# read line datawhile (<IN>) {    chomp;    if (/^end/) { last; }    @data = mysplit($_);}# -----------------------------------------------------------------------# 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 GE data file.\n";print OUT "% "."-" x 78 . "\n";print OUT "% Author:   Juan Carlos Morataya\n";print OUT "% E-mail:   jmorataya\@eegsa.net\n";print OUT "% "."-" x 78 . "\n";print OUT "% 'Generic GE data format "."$ARGV[0]'"."\n";#$ntitle >= 0 && print OUT "% "."-" x 78 . "\n";for ($i = 0; $i <= $ntitle; $i++) { print OUT "% $title[$i]\n"; }$ncom >= 0 && print OUT "% "."-" x 27 . "  Begin  file comments  "."-" x 27 . "\n";for ($i = 0; $i <= $ncom; $i++) { print OUT "% $comment[$i]\n"; }$ncom >= 0 && print OUT "% "."-" x 27 . "   End  file comments   "."-" x 27 . "\n\n";# -----------------------------------------------------------------------# write Bus.con# -----------------------------------------------------------------------$format = "%4d  %8.5f  %8.5f  %8.5f  %2d  %2d;\n";$nbus >= 0 && print OUT "Bus.con = [ ...\n";for ($i = 0; $i <= $nbus; $i++) {    printf OUT $format,$busidx[$i],$kvb[$i],$ein[$i],$ang[$i],    $kae[$i],$kzo[$i];}$nbus >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write SW.con# -----------------------------------------------------------------------if ($nsw >= 0) {    print OUT "SW.con = [ ...\n";    $format = "%4d %7.2f %6.2f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f %8.5f 1 1 1;\n";    $h = $busidx{$swbus};    printf OUT $format,$swbus,$swsb,$kvb[$h],$ein[$h],$ang[$h],$swqt,$swqb,    $vmax[$h],$vmin[$h],$swpg;    print OUT "   ];\n\n";}# -----------------------------------------------------------------------# write PV.con# -----------------------------------------------------------------------$npv >= 0 && printf OUT "PV.con = [ ...\n";$format = "%4d %7.2f %6.2f " . "%8.5f " x 6 . " 1 %2d;\n";for ($i = 0; $i <= $npv; $i++) {    $h = $busidx{$pvbus[$i]};    printf OUT $format,$pvbus[$i],$pvsb[$i],$kvb[$h],$pvpg[$i],$ein[$h],    $pvqt[$i],$pvqb[$i],$vmax[$h],$vmin[$h],$pvstatus[$i];}$npv >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write PQ.con# -----------------------------------------------------------------------$npq >= 0 && printf OUT "PQ.con = [ ...\n";$format = "%4d $pbas %8.2f %8.5f %8.5f %8.5f %8.5f 1 %2d;\n";for ($i = 0; $i <= $npq; $i++) {    $h = $busidx{$pqbus[$i]};    printf OUT $format,$pqbus[$i],$kvb[$h],$pqpl[$i],$pqql[$i],    $vmax[$h],$vmin[$h],$pqstatus[$i];}$npq >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write Pl.con# -----------------------------------------------------------------------$npl >= 0 && print OUT "Pl.con = [ ...\n";$format = "%4d $pbas %8.2f 60 %8.5f %8.5f 0 %8.5f %8.5f 0 0 %2d;\n";for ($i = 0; $i <= $npl; $i++) {    $h = $busidx{$plbus[$i]};    printf OUT $format, $plbus[$i],$kvb[$h],$plyp[$i],    $plip[$i],$plyq[$i],$pliq[$i],$plstatus[$i];}$npl >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write Shunt.con# -----------------------------------------------------------------------$nsh >= 0 && print OUT "Shunt.con = [ ...\n";$format = "%4d $pbas %8.2f 60 %8.5f %8.5f %2d";for ($i = 0; $i <= $nsh; $i++) {    if ($psh[$i] != 0 or $qsh[$i] != 0) {	$h = $busidx{$idxsh[$i]};	printf OUT $format, $h,$kvb[$h],$psh[$i],$qsh[$i],$shstatus[$i];    }}$nsh >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write Line.con# -----------------------------------------------------------------------if ($nline >= 0) {    print OUT "Line.con = [ ...\n";    $format = "%4d %4d %7.2f %7.2f 60 0 " . " %8.5f " x 9 . "%2d;\n";    for ($i = 0; $i <= $nline-1; $i++) {	printf OUT $format,$busfr[$i],$bustt[$i],$pbtf[$i],$linekv[$i],	$kt[$i],$rest[$i],$reat[$i],$susc[$i],$ratio[$i],$phas[$i],	$ratea[$i],$rateb[$i],$ratec[$i],$linestatus[$i];    }    print OUT "   ];\n\n";}# -----------------------------------------------------------------------# write Svc.con# -----------------------------------------------------------------------$nsvc >= 0 && print OUT "Svc.con = [ ...\n";$format = "%4d $pbas %8.2f 60 1 1 10 " . "%8.5f " x 3 . ";\n";for ($i = 0; $i <= $nsvc; $i++) {    $h = $busidx{$idxsvc[$i]};    printf OUT $format,$idxsvc[$i],$kvb[$h],$ein[$h],$svcbma[$i],$svcbmi[$i];}$nsvc >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write Areas.con# -----------------------------------------------------------------------$nzone >= 0 && print OUT "Areas.con = [ ...\n";$format = "%4d 0 $pbas 0 0 0;\n";for ($i = 0; $i <= $nzone; $i++) {    printf OUT $format, $zonenum[$i];}$nzone >= 0 && print OUT "   ];\n\n";# -----------------------------------------------------------------------# write Regions.con# -----------------------------------------------------------------------$narea >= 0 && print OUT "Regions.con = [ ...\n";$format = "%4d %4d $pbas %8.5f %8.5f 0;\n";for ($i = 0; $i <= $narea; $i++) {    printf OUT $format, $areanum[$i],$areaslack[$i],    $areaexp[$i],$areatol[$i];}$narea >= 0 && print 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";# -----------------------------------------------------------------------# write area names# -----------------------------------------------------------------------$nzone >= 0 && print OUT "Areas.names = { ...\n";for ($i = 0; $i <= $nzone-1; $i++) {    print OUT "  '$zonename[$i]';\n";}$nzone >= 0 && print OUT "  '$zonename[$nzone]'};\n\n";# -----------------------------------------------------------------------# write region names# -----------------------------------------------------------------------$narea >= 0 && print OUT "Regions.names = { ...\n";for ($i = 0; $i <= $narea-1; $i++) {    print OUT "  '$areaname[$i]';\n";}$narea >= 0 && print OUT "  '$areaname[$narea]'};\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],$_[2]);    $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 reading comma separated data# -----------------------------------------------------------------------sub mysplit0 {    if ($_ =~  /\s+/)  {	my $string = $_[0];	$string =~ s/://g;	$string =~ s/\s+\"//g;  	$string =~ s/\"//g; 	my @mydata = split /\s+/, $string; 	if ($mydata[0] eq "") { shift(@mydata); } 	return @mydata;     }  }# -----------------------------------------------------------------------# function for reading comma separated data# -----------------------------------------------------------------------sub mysplit {    my $nn = 0;    my @localdata;    $_[0] =~ s/://g;    $_[0] =~ s/\///g;    $nn = 0;    while ($_[0]) {	$_[0] =~ s/\s*-?\d+[\.,]?\d*\s*|\s*\".*?\"\s*//;	$localdata[$nn] = $&;	$localdata[$nn] =~ s/^\s*\"?//;	$localdata[$nn] =~ s/,/\./;	$localdata[$nn] =~ s/\s*\"?\s*$//;	$nn++;	if ($nn > 100) {die "Bad input string (infinite regexp loop...)";}    }    return @localdata;}# -----------------------------------------------------------------------# function for finding multiple PQ loads at the same bus# -----------------------------------------------------------------------sub pqidx {    my $mypqbus = $_[0];    my $check = -1;    for ($i = 0; $i <= $npq; $i++) {	if ($pqbus[$i] == $mypqbus) {	    $check = $i; 	    last;	}	        }	    return $check;}# -----------------------------------------------------------------------# function for finding multiple PV generators at the same bus# -----------------------------------------------------------------------sub pvidx {    my $mypvbus = $_[0];    my $check = -1;    for ($i = 0; $i <= $npv; $i++) {	if ($pvbus[$i] == $mypvbus) {	    $check = $i; 	    last;	}	        }	    return $check;}

⌨️ 快捷键说明

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