#!/bin/sh -x ############################################################ # Computes eigenvalue E = E(x0) for toy-deuteron problem # using "shooting" and bisection search. Uses the following # empirical facts: # # If E_trial > E then u(xmax) > 0 # If E_trial < E then u(xmax) < 0 # # Uses perl scripts # # bsnew # bslo # bshi # bsdone # # which provide rudimentary bisection search facility # # An initial bracket [,] must be provided, as well # as a tolerance for the bisection search. # # Output accumulated in files # x0=/E= ############################################################ P=`basename $0` usage() { printf "$P " printf " []\n" exit 1 } die() { echo "$P $1" exit 1 } case $# in 7|8) x0=$1; Elo=$2; Ehi=$3; Etol=$4; xmax=$5; dxout=$6; lsodatol=$7; vstrace=${8-false}; case $vstrace in true|false) ;; *) "vstrace must be 'true' or 'false'";; esac;; *) usage;; esac # Create results directory if necessary dir="x0=$x0" test -d $dir || mkdir $dir # Initialize the bisection search bsnew $Elo $Ehi # Perform the bisection search while bsnotdone; do Ecurr=`bscurr` ofile="$dir/E=$Ecurr" deut $x0 $Ecurr $xmax $dxout $lsodatol > $ofile $vstrace && nth 1 2 < $ofile | vn $P $x0 flag=`tail -1 $ofile | nth 4` case $flag in 1) bshi;; -1) bslo;; *) echo "$P: Unexpected flag value '$flag'"; exit 1;; esac done nth 1 2 < $ofile > $dir/solution printf "%12s %25s %25s %12s %12s\n" \ $x0 $Ecurr `bsfrac` $dxout $lsodatol >> deut-results