
 ! ******* Feld fuer Pfaddatenverarbeitung ***********************************
_cur_l=0
_snn=0
segmente=4
punkte=200
*set,_path
*dim,_path,table,segmente*punkte,8
!     _path(i,1) = circumferential distance
!     _path(i,2) = Az
!     _path(i,3) = Br
!     _path(i,4) = mechanical angle (D)
!     _path(i,5) = PV02 (integran)
!     _path(i,6) = torq (torque)
!  number of data points in the _path array = _i_s in this array
!  _cur_l = total length of the path
_path(0,0)=1e-7
_path(0,1)=1
_path(0,2)=2
_path(0,3)=3
_path(0,4)=4
_path(0,5)=5
_path(0,6)=6
_path(0,7)=7
_path(0,8)=8

CMSEL,S,KSTATOR 
ALLSEL,BELOW,AREA   
csys,1  
NSEL,a,LOC,X,0,rinnen+jochdicke2+delta/2
cm,_nstat,node

! loop ueber alle Segmente ******************************************************

_jj=1
 *do,_jj,1,segmente,1
   csys,1
   cmsel,s,_nstat
   nsel,r,loc,y,(_jj-1)*360/segmente,_jj*360/segmente
   local,100,1
   cscir,100,1
   *if,_wa,gt,180,then
   cscir,100,0
   *endif
    !set,last
   *get,_we,node,,mxloc,y               ! Endwinkel
   *get,_wa,node,,mnloc,y               ! Anfangswinkel
   *if,(_jj-1)*360/segmente,ge,350,then
   *get,_wa,node,,mxloc,y               ! Endwinkel
   _we=0
   *endif
   rsys,100
   path,pfad%_jj%,2,30,punkte
   ppath,1,node(rinnen+jochdicke2+delta/2,_wa,0),,,1
   ppath,2,node(rinnen+jochdicke2+delta/2,_we,0),,,1
   dsys
   _wa=_we
   ! Label f. Lufspaltfeld
   pdef,_bx,b,x
   pdef,_by,b,y
   !    computes the angle
   pcalc,add,cir,s,,,,_cur_l
   pcalc,add,ang,cir,,(1/(rinnen+jochdicke2+delta/2))*180/3.141593
   *get,_cur_l,path,,max,cir
   rsys
   csys


  *set,_unsort
  paget,_unsort,table
  ! sortieren der Daten fuer spaetere Anwendung
  *vfun,_path(1+_snn,0),copy,_unsort(1,18)
  *vfun,_path(1+_snn,1),copy,_unsort(1,16)
  *vfun,_path(1+_snn,2),copy,_unsort(1,17)
  *vfun,_path(1+_snn,3),copy,_unsort(1,8)
  *vfun,_path(1+_snn,4),copy,_unsort(1,12)
  *vfun,_path(1+_snn,5),copy,_unsort(1,15)
  *vfun,_path(1+_snn,6),copy,_unsort(1,5)
  *vfun,_path(1+_snn,7),copy,_unsort(1,6)
  _snn=punkte+_snn

*enddo
! ***** ENDE LOOP UEBER ALLE SEGMENTE *******************************************

 *endif
*endif
! ***************************************************************************
! ****** ENDE der Pfadbereitstellung fuer Momentberechnung ******************
! ****** und Luftspaltfeld **************************************************
! ***************************************************************************


! ***************************************************************************
! ***** Luftspaltfeld *******************************************************
! ***************************************************************************
_lsfeld=1

*if,_lsfeld,eq,1,then
 /reset
 /axlab,x,Pfadwinkel in Grad 
 /axlab,y,B_r  in T
 /grid,1
 /xrange,0,360
 /yrange,-luftskal,luftskal
 /GCOL,1,'B radial'
!! _qk=_nust(_us,1)               ! Winkel
 /title,Luftspaltfeld der Maschine bei t=%zeit%
/show,Plots%ausgabe%,grph,,append
 *vplo,_path(1,3),_path(1,6)!!!,7
 _nonie=1
*endif

*if,_fft,eq,1,then

_asy=1
_womit=0
_modemax=120

 _mode=
 _modeb=
 _modeg=
 _coeff=
 _coeff1=
 _coeff2=
 _coeff_0=
 _coeff_1=
 _coeffi=
 _coeffig=
 _coeffib=
 _phix=
 _phiy=
 _phiyo=
 _isy=
 _isyg=
 _isy1=
 _isy0=
 _feld=6+%_womit%

 *dim,_mode,array,2*_modemax+1
 _mode(1)=0
 *Do,_jj,1,_modemax
 _mode(2*_jj)=_jj
 _mode(2*_jj+1)=_jj   
 *EndDo 
 *dim,_coeff_0,array,_modemax
 *dim,_coeff_1,array,_modemax
 *dim,_isy,array,2*_modemax+1
 _isy(1)=0
 *Do,_jj,1,_modemax
 _isy(2*_jj)=_jj
 _isy(2*_jj+1)=-_jj   
 *EndDo 
 *dim,_isy0,array,_modemax
 *vfill,_isy0(1),ramp,1,0
 *dim,_isy1,array,_modemax
 *vfill,_isy1(1),ramp,-1,0
 *dim,_phix,table,segmente*punkte
 *dim,_phiy,table,segmente*punkte,2
 *dim,_phiyo,table,segmente*punkte
 *dim,_coeff,array,_modemax-1,
 *dim,_coeff1,array,_modemax-1,
 *dim,_coeff2,array,_modemax-1,
 *dim,_coeffi,array,2*_modemax+1,
 *dim,_coeffib,array,_modemax+1,
 *dim,_modeb,array,_modemax+1,
 *dim,_isyg,array,2*p+1
 *dim,_modeg,array,2*p+1
 *dim,_coeffig,array,2*p+1

 *voper,_phix(1),_phix(1),add,_path(1,3)
 *voper,_phiy(1),_phiy(1),add,_path(1,_feld)

  *mfour,fit,_coeffi(1),_mode(1),_isy(1),_phix(1),_phiy(1)
  /axlab,y,Koeff. der geraden per. Funktion
  /axlab,y,Betrag der Oberwellen
!! *endif
 /axlab,x,Mode Nummer
 *if,%_womit%,eq,1,then
 /title,Fourierreihenzerlegung Tangentialfeld
 *else
 /title,Fourierreihenzerlegung Radialfeld
 *endif
 /grop,fill,1
 /gthk,axis,3
 /gropt,divx,_modemax-1
 /xrange,1,_modemax
 /yrange,0,luftskal
 /gropt,ltyp,0
 /gcolu,1,koeff
 
 _coeffib(1)=_coeffi(1)
 _modeb(1)=0
 null=0
/output,Fourierkoeffizienten%ausgabe%Zeit%zeit%s,lis
/COM,--------------------------------------------------------------------
/COM,   Wellenordnung    a(gerade)   b(ungerade)   c(Betrag)    Phase
/COM,--------------------------------------------------------------------
/output,term

 *Do,_jj,1,_modemax
 _coeffib(_jj+1)=_coeffi(2*_jj)*_coeffi(2*_jj)+_coeffi(2*_jj+1)*_coeffi(2*_jj+1) 
 _coeffib(_jj+1)=sqrt(_coeffib(_jj+1))
 _modeb(_jj+1)=_jj
 *If,_coeffib(_jj+1),gt,1e-6,then
*set,a,_modeb(_jj+1)
*set,b,_coeffi(2*_jj)
*set,c,_coeffi(2*_jj+1)
*set,d,_coeffib(_jj+1)
/output,Fourierkoeffizienten%ausgabe%Zeit%zeit%s,lis,,append
 *VWrite,a,b,c,d
 (4(g16.6,' '))
 /output,term
 *EndIf

 *EndDo
 *Do,_jj,1,2*p+1
 _modeg(_jj)=_mode(_jj)
 _isyg(_jj)=_isy(_jj)
 _coeffig(_jj)=_coeffi(_jj)
 *EndDo 
/show,Plots%ausgabe%,grph,,append
 *vplot,_modeb(1),_coeffib(1)
 !*stat,_coeff
 _nonie=1
  *mfour,eval,_coeffig(1),_modeg(1),_isyg(1),_phix(1),_phiyo(1)
  *vfun,_phiy(1,2),copy,_phiyo(1,1)
 /reset
 /axlab,x,Pfadwinkel in Grad 
 /axlab,y,B_r  in T
 /grid,1
 /xrange,0,360
 /yrange,-luftskal,luftskal
 /GCOL,1,'B radial'
 /title,Luftspaltfeld der Maschine und Grundwelle bei t=%zeit%
/show,Plots%ausgabe%,grph,,append
 *vplo,_phix(1,1),_phiy(1,1),2
/title

*endif
