START ===== ShotCalculator.cmd
:: File:ShotCalculator.cmd - Docs at the end
@echo off
:: TURN OF ECHO IN CMD
echo SET THE BASEDIRECTORY OF THE SCRIPT
set BaseDir=D:\perl\sfw\FF\ShotCalculator
echo :: BaseDir --- %BaseDir
echo Set the full path to the Perl Script
set PerlScript=%BaseDir%\ShotCalculator.pl
echo :: PerlScript --- %PerlScript%
echo set the Initial Current - This is the initial current of 100,000 Joules enters the system
set InitialCurrent=100000
echo :: InitialCurrent --- %InitialCurrent%
echo set the PinchCurrent - About 70,000 go toward generating the “pinch” and making fusion happen.
set PinchCurrent=70000
echo :: PinchCurrent --- %PinchCurrent%
echo set the FusionYieldPerPinch - The theoretical yield of the pinch of fusion-generated energy
set FusionYieldPerPinch=33000
echo FusionYieldPerPinch --- %FusionYieldPerPinch%
echo set the time for which we would like to calculate the energy gains in time units ( seconds )
set TimeOfOperation=3600
echo TimeOfOperation --- %TimeOfOperation%
echo set the amount of pinches that are ran per second
set PinchesPerTimeUnit=5
echo PinchesPerTimeUnit --- %PinchesPerTimeUnit%
echo This is the percentage of the ennergy loss occuring per shot
set EnergyLossCoefficient=24.8125
echo EnergyLossCoefficient --- %EnergyLossCoefficient%
echo This is the percentage of the ennergy loss occuring per shot
set OutputDir=%BaseDir%\output
echo OutputDir --- %OutputDir%
echo make the OutputDir %OutputDir% if it does not exist
mkdir %OutputDir%
echo ignore any error message if it appears ...
echo Call The Perl Script as follows
echo perl %PerlScript% %InitialCurrent% %PinchCurrent% %FusionYieldPerPinch%
perl %PerlScript% %InitialCurrent% %PinchCurrent% %FusionYieldPerPinch% %TimeOfOperation% %PinchesPerTimeUnit% %EnergyLossCoefficient% %OutputDir%
echo Now open the OutputDir %OutputDir%
cmd /t30 /c start /max Explorer /e , %OutputDir%
echo Done in cmd
:: Purpose:to set the variables need for Focus Fusion Shot Calculations during time
:: VersionHistory:
:: 1.0.20101009_151621 --- Yordan Georgiev -- Initial draft based on http://focusfusion.org/index.php/site/article/how_will_we_get_there_from_here/
::
END ================== ShotCalculator.cmd
.
START ===== ShotCalculator.pl
use strict ;
package ShotCalculator ;
my $InitialCurrent = $ARGV[0] ; #This is the initial current of 100,000 Joules enters the system
my $PinchCurrent = $ARGV[1] ; #About 70,000 go toward generating the “pinch” and making fusion happen.
my $FusionYieldPerPinch = $ARGV[2] ; #The theoretical yield of the pinch of fusion-generated energy
my $TimeOfOperation = $ARGV[3] ; #This is the time for which we would like to calculate the energy gains
my $PinchesPerTimeUnit = $ARGV[4] ; #How many pinches are run per second
my $EnergyLossCoefficient = $ARGV[5] ; #Less ~20% energy lost by inefficiencies and you end up with the 106,400 Joules.
my $OutputDir=$ARGV[6] ; #The directory where the output will be saved
my $OutputFile = "$OutputDir" . '/' . "InitialCurrent" . '-' . "$InitialCurrent" . '_' . "PinchCurrent" . '-' . "$PinchCurrent" . '_' . "FusionYieldPerPinch" . '-' . "$FusionYieldPerPinch" . '_' . "TimeOfOperation" . '-' . "$TimeOfOperation" . '_' . "PinchesPerTimeUnit" . '-' . "$PinchesPerTimeUnit" . '_' . "EnergyLossCoefficient" . '-' . "$EnergyLossCoefficient" . '.csv';
sub main
{
#debug print " \$InitialCurrent --- $InitialCurrent \n " ;
#debug print " \$PinchCurrent = $PinchCurrent \n " ;
#debug print " \$FusionYieldPerPinch = $FusionYieldPerPinch \n" ;
#debug print " \$TimeOfOperation = $TimeOfOperation \n";
#debug print " \$PinchesPerTimeUnit --- $PinchesPerTimeUnit \n" ;
#debug print " \$EnergyLossCoefficient --- $EnergyLossCoefficient \n " ;
open ( OUTPUTFILE , ">$OutputFile" ) || print "Cannot open \$OutputFile - $OutputFile !!!" ;
print OUTPUTFILE "InitialCurrent PinchCurrent FusionYieldPerPinch TimeOfOperation PinchesPerTimeUnit EnergyLossCoefficient IonBeamConversionDeviceRecoveryPerTU RecoveredCurrentPerTU TotalEnergyRecoveredPerTU NetGainPerTU CumIonBeamConversionDeviceRecovery CumRecoveredCurrent CumTotalEnergyRecovered CumNetGain\n";
my ( $CumIonBeamConversionDeviceRecovery , $CumRecoveredCurrent , $CumTotalEnergyRecovered , $CumNetGain ) = 0;
for (my $TimeUnit = 0 ; $TimeUnit < $TimeOfOperation ; $TimeUnit++)
{
my ($IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain) = CalculateSingleShot() ;
print OUTPUTFILE "$InitialCurrent $PinchCurrent $FusionYieldPerPinch $TimeOfOperation $PinchesPerTimeUnit $EnergyLossCoefficient " ;
#debug print " \$IonBeamConversionDeviceRecovery , \$RecoveredCurrent , \$TotalEnergyRecovered , \$NetGain \n" ;
#debug print " $IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain \n" ;
my ($IonBeamConversionDeviceRecoveryPerTU , $RecoveredCurrentPerTU , $TotalEnergyRecoveredPerTU , $NetGainPerTU) = CalculatePerTimeUnit ( $IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain ) ;
#debug print "\$IonBeamConversionDeviceRecoveryPerTU , \$RecoveredCurrentPerTU , \$TotalEnergyRecoveredPerTU , \$NetGainPerTU \n " ;
#debug print "$IonBeamConversionDeviceRecoveryPerTU , $RecoveredCurrentPerTU , $TotalEnergyRecoveredPerTU , $NetGainPerTU \n " ;
print OUTPUTFILE "$IonBeamConversionDeviceRecoveryPerTU $RecoveredCurrentPerTU $TotalEnergyRecoveredPerTU $NetGainPerTU " ;
$CumIonBeamConversionDeviceRecovery = $CumIonBeamConversionDeviceRecovery + $IonBeamConversionDeviceRecoveryPerTU ;
$CumRecoveredCurrent = $CumRecoveredCurrent + $RecoveredCurrentPerTU;
$CumTotalEnergyRecovered = $CumTotalEnergyRecovered + $TotalEnergyRecoveredPerTU ;
$CumNetGain = $CumNetGain + $NetGainPerTU ;
print OUTPUTFILE "$CumIonBeamConversionDeviceRecovery $CumRecoveredCurrent $CumTotalEnergyRecovered $CumNetGain\n" ;
} #eof for
#now close the file
close OUTPUTFILE ;
} #eof sub main
sub CalculateSingleShot
{
#This is the amount of energy to be recovered by the ion beam conversion device
#70,000 + 33,000 gives us 103,000 Joules of energy to be recovered in the ion beam conversion device.
my $IonBeamConversionDeviceRecovery = $PinchCurrent + $FusionYieldPerPinch ;
#The other 30,000 are not lost. They are recovered/recycled – stored in a second capacitor bank called the mirror capacitors that is charging up for the next shot.
my $RecoveredCurrent = $InitialCurrent - $PinchCurrent ;
#70,000 + 33,000 gives us 103,000 Joules of energy to be recovered in the ion beam conversion device. 103,000 Joules from the ion beam conversion device + 30,000 recovered from the shot gives us 133,000 Joules.
my $TotalEnergyRecovered = $IonBeamConversionDeviceRecovery + $RecoveredCurrent ;
#Less ~20% energy lost by inefficiencies and you end up with the 106,400 Joules.
my $NetGain = ( $TotalEnergyRecovered * (( 100 - $EnergyLossCoefficient )/100) ) - $InitialCurrent;
#return the values
return ($IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain) ;
} #eof sub CalculateSingleShot
# ====================================================================
#This function calculates the vars per time unit
sub CalculatePerTimeUnit
{
my $IonBeamConversionDeviceRecovery = shift ;
my $RecoveredCurrent = shift ;
my $TotalEnergyRecovered = shift ;
my $NetGain = shift ;
$IonBeamConversionDeviceRecovery = $IonBeamConversionDeviceRecovery * $PinchesPerTimeUnit ;
$RecoveredCurrent = $RecoveredCurrent * $PinchesPerTimeUnit ;
$TotalEnergyRecovered = $TotalEnergyRecovered * $PinchesPerTimeUnit ;
$NetGain = $NetGain * $PinchesPerTimeUnit ;
return ($IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain) ;
#my ($CumIonBeamConversionDeviceRecovery , $CumRecoveredCurrent , $CumTotalEnergyRecovered , $CumNetGain) = $PinchesPerTimeUnit * ($IonBeamConversionDeviceRecovery , $RecoveredCurrent , $TotalEnergyRecovered , $NetGain) ;
} #eof sub CalculateSingleShot
# ====================================================================
# Action !!!
main();
1 ;
__END__
#Purpose: This script is aimed to simulate Focus Fusion energy calculations as well as print those in simple csv files
#License: None. Do whatever you want with this software on your own responsibility ...
#VersionHistory:
#1.0.20101009_171145 --- Yordan Georgiev --- Initial Creation - Prints a csv file with all the parameters
END ================== ShotCalculator.pl
START ===== list.txt
this is the perl script - contains the logic of the calculation
ShotCalculator.pl,http://docs.google.com/document/edit?id=1PBKpmBkGLoKITleNphNaafHj4YLAsRUOqg-bvmR1QW0&hl=en
which could be called from a cmd batch file on Win , this one has the params
ShotCalculator.cmd,http://docs.google.com/document/edit?id=1xV5hnHi2hCPsIrIXQ66u3XMaoZqNJqMjr9hE22rZ5tc&hl=en
this is a fast NON-TESTED prototype for how the sh script to call it on Unix / LInux might look like ...
ShotCalculator.sh,http://docs.google.com/document/edit?id=15BMn_EMIAhJNmHD4b9NCMaWIGHzMYqhc9TbH9T4eJwc&hl=en
And here some result files
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-1_PinchesPerTimeUnit-10_EnergyLossCoefficient-20,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdGVpZ182S1Rhd2xTUnRKeFVtR29fcnc&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-10_EnergyLossCoefficient-20,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdGtadEVYVE1FRFBRVmhlWGkzSi0yU0E&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-1_EnergyLossCoefficient-20,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdE5JLW16Qm5EM0VqSWVVVU9USzExQmc&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-20,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdFhBalFTazRGR2M0eGxYUXpoUkpaYXc&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-22,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdHlibDlGc0tFQm1TamNBa2lhN3hNVVE&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-24,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdC1nUW93cVk0TDVsM2hBZ2hoUWk3YkE&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-24,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdGVvTG1ER2JHMnhQVDZIMjBKVzBSOHc&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-25,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdDNfVzd2S1pkUmlsaDZ4NEp4dXh5SUE&hl=en
InitialCurrent-100000_PinchCurrent-70000_FusionYieldPerPinch-33000_TimeOfOperation-3600_PinchesPerTimeUnit-5_EnergyLossCoefficient-30,http://spreadsheets.google.com/ccc?key=0AnfD4zJrQugmdHc4TV9fazE1ems1WHh5eHJyRXlZa0E&hl=en
END ================== list.txt
.
.
START ===== ShotCalculator.sh
#This is not tested ... because of basic laziness ... it might have couple of bugs ...
#File:ShotCalculator.sh - Docs at the end
#TURN OF ECHO IN CMD
echo SET THE BASEDIRECTORY OF THE SCRIPT
BaseDir=/home/userName/ff
echo #BaseDir --- BaseDir
echo Set the full path to the Perl Script
PerlScript=BaseDir\ShotCalculator.pl
echo #PerlScript --- PerlScript
echo the Initial Current - This is the initial current of 100,000 Joules enters the system
InitialCurrent=100000
echo #InitialCurrent --- InitialCurrent
echo the PinchCurrent - About 70,000 go toward generating the “pinch” and making fusion happen.
PinchCurrent=70000
echo #PinchCurrent --- PinchCurrent
echo the FusionYieldPerPinch - The theoretical yield of the pinch of fusion-generated energy
FusionYieldPerPinch=33000
echo FusionYieldPerPinch --- FusionYieldPerPinch
echo the time for which we would like to calculate the energy gains in time units ( seconds )
TimeOfOperation=3600
echo TimeOfOperation --- TimeOfOperation
echo the amount of pinches that are ran per second
PinchesPerTimeUnit=5
echo PinchesPerTimeUnit --- PinchesPerTimeUnit
echo This is the percentage of the ennergy loss occuring per shot
EnergyLossCoefficient=24.5
echo EnergyLossCoefficient --- EnergyLossCoefficient
echo This is the percentage of the ennergy loss occuring per shot
OutputDir=BaseDir\output
echo OutputDir --- OutputDir
echo make the OutputDir $OutputDir if it does not exist
mkdir $OutputDir
echo ignore any error message if it appears ...
echo Call The Perl Script as follows
echo $PerlScript $InitialCurrent $PinchCurrent $FusionYieldPerPinch $TimeOfOperation $PinchesPerTimeUnit $EnergyLossCoefficient $OutputDir
perl $PerlScript $InitialCurrent $PinchCurrent $FusionYieldPerPinch $TimeOfOperation $PinchesPerTimeUnit $EnergyLossCoefficient $OutputDir
ls -al $OutputDir
echo Done in cmd
#Purpose:to the variables need for Focus Fusion Shot Calculations during time
#VersionHistory:
#1.0.20101009_151621 --- Yordan Georgiev -- Initial draft based on h://focusfusion.org/index.php/site/article/how_will_we_get_there_from_here/
END ================== ShotCalculator.sh
Getting the Current TabItem when the Tab is not selected in WPF
-
[image: Banner]
This is a quick reminder to self on how to retrieve a TabItem from a WPF
TabControl *when the tab is not currently selected* because I ru...
1 week ago
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!