Skip to content

Commit

Permalink
spin normal form
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsignorelli committed Jul 19, 2024
1 parent 32d6f36 commit 660bf62
Show file tree
Hide file tree
Showing 19 changed files with 2,338 additions and 1,016 deletions.
1 change: 1 addition & 0 deletions fpp-ptc-sandbox/code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set (EXE_SPECS
cmake_files/cmake.z_canonize_matt_fake_maps
cmake_files/cmake.z_resonance
cmake_files/cmake.z_spin1
cmake_files/cmake.z_spin_res
)


Expand Down
20 changes: 20 additions & 0 deletions fpp-ptc-sandbox/code/EQUATION.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

etall 1, NO = 2, NV = 6, INA = 56
*********************************************

I COEFFICIENT ORDER EXPONENTS
NO = 2 NV = 6
0 -0.1604272270583351E-13 0 0 0 0 0 0
1 3.532841697202252 1 0 0 0 0 0
1 0.4306530717865838 0 1 0 0 0 0
-3 0.000000000000000 0 0 0 0 0 0

etall 1, NO = 2, NV = 6, INA = 57
*********************************************

I COEFFICIENT ORDER EXPONENTS
NO = 2 NV = 6
0 0.1842970220877760E-13 0 0 0 0 0 0
1 -2.342063456623922 1 0 0 0 0 0
1 -3.255712043070225 0 1 0 0 0 0
-3 0.000000000000000 0 0 0 0 0 0
41 changes: 41 additions & 0 deletions fpp-ptc-sandbox/code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,19 @@ z_spin1-exe/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin1-exe.dir/build.make CMakeFiles/z_spin1-exe.dir/build
.PHONY : z_spin1-exe/fast

#=============================================================================
# Target rules for targets named z_spin_res-exe

# Build rule for target.
z_spin_res-exe: cmake_check_build_system
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 z_spin_res-exe
.PHONY : z_spin_res-exe

# fast build rule for target.
z_spin_res-exe/fast:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin_res-exe.dir/build.make CMakeFiles/z_spin_res-exe.dir/build
.PHONY : z_spin_res-exe/fast

normal_simple.o: normal_simple.f90.o
.PHONY : normal_simple.o

Expand Down Expand Up @@ -860,6 +873,30 @@ z_spin1.f90.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin1-exe.dir/build.make CMakeFiles/z_spin1-exe.dir/z_spin1.f90.s
.PHONY : z_spin1.f90.s

z_spin_res.o: z_spin_res.f90.o
.PHONY : z_spin_res.o

# target to build an object file
z_spin_res.f90.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin_res-exe.dir/build.make CMakeFiles/z_spin_res-exe.dir/z_spin_res.f90.o
.PHONY : z_spin_res.f90.o

z_spin_res.i: z_spin_res.f90.i
.PHONY : z_spin_res.i

# target to preprocess a source file
z_spin_res.f90.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin_res-exe.dir/build.make CMakeFiles/z_spin_res-exe.dir/z_spin_res.f90.i
.PHONY : z_spin_res.f90.i

z_spin_res.s: z_spin_res.f90.s
.PHONY : z_spin_res.s

# target to generate assembly for a file
z_spin_res.f90.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/z_spin_res-exe.dir/build.make CMakeFiles/z_spin_res-exe.dir/z_spin_res.f90.s
.PHONY : z_spin_res.f90.s

z_sub_i.o: z_sub_i.f90.o
.PHONY : z_sub_i.o

Expand Down Expand Up @@ -1030,6 +1067,7 @@ help:
@echo "... z_shift-exe"
@echo "... z_simple_operations-exe"
@echo "... z_spin1-exe"
@echo "... z_spin_res-exe"
@echo "... z_sub_i-exe"
@echo "... z_sub_j-exe"
@echo "... z_track_da_tpsa-exe"
Expand Down Expand Up @@ -1090,6 +1128,9 @@ help:
@echo "... z_spin1.o"
@echo "... z_spin1.i"
@echo "... z_spin1.s"
@echo "... z_spin_res.o"
@echo "... z_spin_res.i"
@echo "... z_spin_res.s"
@echo "... z_sub_i.o"
@echo "... z_sub_i.i"
@echo "... z_sub_i.s"
Expand Down
14 changes: 14 additions & 0 deletions fpp-ptc-sandbox/code/cmake_files/cmake.z_spin_res
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set (EXENAME z_spin_res)

FILE (GLOB SRC_FILES z_spin_res.f90)

set (INC_DIRS
)

set (LINK_LIBS
forest
bsim
bmad
sim_utils
${ACC_BMAD_LINK_LIBS}
)
18 changes: 10 additions & 8 deletions fpp-ptc-sandbox/code/fit_tune.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
select layout
1
L MAX
1.0000000000000000E-002
CUTTING ALGORITHM
2
LIMIT FOR CUTTING
10000 10000
MISALIGN EVERYTHING
0.001 0.001 0.001 0.001 0.001 0.001 5
set families
2
1 qf1
2 1
1 qd1
2 2
FITTUNE
0.0000000001
0.367269834767751 0.404042919 !2293877 !6057 0.336 0.218992743820551
deallocate families
return
Empty file added fpp-ptc-sandbox/code/plot.dat
Empty file.
560 changes: 280 additions & 280 deletions fpp-ptc-sandbox/code/spinmap.txt

Large diffs are not rendered by default.

56 changes: 31 additions & 25 deletions fpp-ptc-sandbox/code/z_resonance.f90
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,37 @@ program Resonance
!kall c_linear_a(T,A)
!call print(A)
! stop

!call print(T)
!stopS
res=.true.

normal_form%positive=.false.
if(res) normal_form%nres=(c_%no+1)/3
write(6,*) " # of resonance terms ",normal_form%nres
do i=1, (c_%no+1)/3
if(res) normal_form%m(1,i)=3*i ! 1/3 order
enddo

mr2=0
if(res) then
do i=1,c_%nd
mr2=mr2+normal_form%m(i,1)**2
enddo

s=0
do i=1,c_%nd
mu(i)=phat(i)
s=s+normal_form%m(i,1)*mu(i)
mu(i)=mu(i)*twopi
enddo
p_res=nint(s)
endif

call c_normal(T,normal_form,phase=phat,canonize=.true.)
write(*,*) "this should not have been reached"
call print(normal_form%atot)
write(*,*) "+========================================="
stop
!write(*,*) "this should not have been reached"
T = ci_phasor()*normal_form%atot**(-1)*T*normal_form%atot*c_phasor()
call print(T)
stop
Expand All @@ -192,29 +220,7 @@ program Resonance



res=.true.

normal_form%positive=.false.
if(res) normal_form%nres=(c_%no+1)/3
write(6,*) " # of resonance terms ",normal_form%nres
do i=1, (c_%no+1)/3
if(res) normal_form%m(1,i)=3*i ! 1/3 order
enddo

mr2=0
if(res) then
do i=1,c_%nd
mr2=mr2+normal_form%m(i,1)**2
enddo

s=0
do i=1,c_%nd
mu(i)=phat(i)
s=s+normal_form%m(i,1)*mu(i)
mu(i)=mu(i)*twopi
enddo
p_res=nint(s)
endif



call c_normal(T,normal_form,canonize=.true.)
Expand Down
60 changes: 49 additions & 11 deletions fpp-ptc-sandbox/code/z_spin1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ program Guignard_normal_form_average_x
ALS=>m_u%start

call build_lattice(ALS,mis,exact=.false.,thin=.false.,onecell=.false.)



!call read_ptc_command77("fit_tune.txt")
p=>als%start
misa=0
call move_to(als,p,"BEND")
if(state%nocavity) then
Expand All @@ -69,6 +64,41 @@ program Guignard_normal_form_average_x
misa=0.1d0*misa
call MISALIGN_FIBRE(p,misa)

call kanalnummer(mf,file="fit_tune.txt")
write(mf,*) "select layout"
write(mf,*) " 1 "
write(mf,*) "set families "
write(mf,*) " 2 "
write(mf,*) " 1 qf1 "
write(mf,*) "2 1 "
write(mf,*) " 1 qd1 "
write(mf,*) "2 2 "
write(mf,*) "FITTUNE "
write(mf,*) "0.0000000001 "
write(mf,*) "0.367269834767751 0.404042919 !2293877 !6057 0.336 0.218992743820551 "
write(mf,*) "deallocate families "
write(mf,*) "return"
close(mf)



call read_ptc_command77("fit_tune.txt")


!call read_ptc_command77("fit_tune.txt")
! p=>als%start
! misa=0
! call move_to(als,p,"BEND")
! if(state%nocavity) then
! misa(4)=0.03d0
! misa(6)=0.03d0
! else
! misa(4)=0.003d0
! misa(6)=0.003d0
! endif
! misa=0.1d0*misa
! call MISALIGN_FIBRE(p,misa)
!
courant_snyder_teng_edwards=.true.
time_lie_choice=.true.

Expand All @@ -85,13 +115,14 @@ program Guignard_normal_form_average_x
MY_DELTA=>mondelta
my_fix=>closed_orbit

!call phase_advance_n(6)
!call phase_advance_n()
!write(*,*) "hi"
!write(6,format3) als%end%tm%lf%k(1,2,2)
write(6,format3) als%end%t2%lf%phase
write(6,format3) als%end%t2%lf%damping
write(6,format3) als%end%t2%lf%spin
write(6,format1) als%end%t2%lf%phase(1)*5

!stop
!goto 1001
call kanalnummer(mf,"C:\document\my_tex_papers\fpp_handbook\julia\lat.txt")

Expand All @@ -101,7 +132,6 @@ program Guignard_normal_form_average_x
map_order=3
skew=.true.


call init_all(state,map_order,0)

call alloc(one_turn_map, id_s,U_c,A,U,a_cs,N_c )
Expand Down Expand Up @@ -131,16 +161,24 @@ program Guignard_normal_form_average_x
call print(one_turn_map,i)
close(I)
!stop
normal_form%nres=1
normal_form%m(2,1)=1
normal_form%ms(1)=-1
write(*,*) "entering NF"
call c_normal(one_turn_map,normal_form,dospin=state%spin,phase=phase) ! (6)
write(*,*) "exiting NF"
id_s=one_turn_map


one_turn_map=ci_phasor()*normal_form%atot**(-1)*id_s*normal_form%atot*c_phasor()
one_turn_map%e_ij = 0
call clean(one_turn_map, one_turn_map, prec=1.e-7_dp)
one_turn_map%e_ij = 0
!call c_q0_to_qr(one_turn_map%q, one_turn_map%q) ! only necessary when leaving spin resonance in so we make i, k parts 0
call print(one_turn_map)
stop


!call c_q0_to_qr(one_turn_map%q, one_turn_map%q) ! only necessary when leaving spin resonance in so we make i, k parts 0
call print(one_turn_map%q)
write(*,*) "hi"
stop

Expand Down
Loading

0 comments on commit 660bf62

Please sign in to comment.