Home > lattice > mvelem.m

mvelem

PURPOSE ^

MVELEM(ELEMPOS, DIST) moves an element located at ELEMPOS in THERING

SYNOPSIS ^

function mergedrift(ELEMPOS, DIST)

DESCRIPTION ^

MVELEM(ELEMPOS, DIST) moves an element  located at ELEMPOS in THERING
 surrounded by two DRIFT spaces 
 
  0   < DIST  < LD move downstream
 -LU  < DIST  < 0  move upstream
  where LU and LD - lenths of 
  upstream and downstrem drift drifts BEFORE!!! the move 

 Number of elements in THERING and total length remain the same

 See also: SPLITDRIFT, MERGEDRIFT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mergedrift(ELEMPOS, DIST) 
0002 %MVELEM(ELEMPOS, DIST) moves an element  located at ELEMPOS in THERING
0003 % surrounded by two DRIFT spaces
0004 %
0005 %  0   < DIST  < LD move downstream
0006 % -LU  < DIST  < 0  move upstream
0007 %  where LU and LD - lenths of
0008 %  upstream and downstrem drift drifts BEFORE!!! the move
0009 %
0010 % Number of elements in THERING and total length remain the same
0011 %
0012 % See also: SPLITDRIFT, MERGEDRIFT
0013 
0014 global THERING
0015 
0016 L0 = THERING{ELEMPOS-1}.Length + THERING{ELEMPOS}.Length + THERING{ELEMPOS+1}.Length;
0017 
0018 if DIST > THERING{ELEMPOS+1}.Length 
0019     error('Cannot move downstream more than the length of downstream drift');
0020 elseif -DIST > THERING{ELEMPOS-1}.Length 
0021     error('Cannot move upstream more than the length of upstream drift');
0022 else
0023     THERING{ELEMPOS+1}.Length = THERING{ELEMPOS+1}.Length - DIST;
0024     THERING{ELEMPOS-1}.Length = THERING{ELEMPOS-1}.Length + DIST;
0025 end
0026 
0027         
0028

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005