Skip to content

Commit

Permalink
Merge pull request #347 from PrincetonUniversity/bugfix/SOPT_VMEC_sca…
Browse files Browse the repository at this point in the history
…ling

Bugfix/sopt vmec scaling
  • Loading branch information
lazersos authored Feb 5, 2025
2 parents 10941e9 + 3ca2d3b commit 8b80d1e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 32 deletions.
37 changes: 37 additions & 0 deletions LIBSTELL/Sources/Modules/vmec_input.f
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,43 @@ SUBROUTINE INDATA_AREA(area)
RETURN
END SUBROUTINE INDATA_AREA

SUBROUTINE RESCALE_BOUNDARY
IMPLICIT NONE
REAL(rprec) :: AVolume, AArea, AR00, TArea
IF (tvolume .gt. 0.0) THEN
CALL INDATA_VOLUME(AVolume)
IF (lvolume_rfix) THEN
CALL INDATA_AREA(AArea)
AR00 = AVolume/(twopi * AArea)
TArea = TVolume/(twopi * AR00)
raxis_cc = rbc(0:ntord,0)
zaxis_cs = zbs(0:ntord,0)
rbc = rbc * (Tarea / Aarea) ** (1.0/2.0)
zbs = zbs * (Tarea / Aarea) ** (1.0/2.0)
rbc(0:ntord,0) = raxis_cc(0:ntord)
zbs(0:ntord,0) = zaxis_cs(0:ntord)
IF (lasym) THEN
raxis_cs = rbs(0:ntord,0)
zaxis_cc = zbc(0:ntord,0)
rbs = rbs * (Tarea / Aarea) ** (1.0/2.0)
zbc = zbc * (Tarea / Aarea) ** (1.0/2.0)
rbs(0:ntord,0) = raxis_cs(0:ntord)
zbc(0:ntord,0) = zaxis_cc(0:ntord)
END IF
ELSE
rbc = rbc * (tvolume / AVolume) ** (1.0/3.0)
zbs = zbs * (tvolume / AVolume) ** (1.0/3.0)
IF (lasym) THEN
rbs = rbs * (tvolume / AVolume) ** (1.0/3.0)
zbc = zbc * (tvolume / AVolume) ** (1.0/3.0)
END IF
ENDIF
CALL INIT_AXIS_MIDPOINT
END IF
RETURN
END SUBROUTINE RESCALE_BOUNDARY


SUBROUTINE INIT_AXIS_MEAN
IMPLICIT NONE
INTEGER :: n
Expand Down
1 change: 1 addition & 0 deletions STELLOPTV2/Sources/General/stellopt_write_inputfile.f90
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ SUBROUTINE stellopt_write_inputfile(ncnt,lmin)
SELECT CASE(TRIM(equil_type))
CASE('vmec2000','animec','flow','satire','parvmec','paravmec','vboot','vmec2000_oneeq')
IF (lcoil_geom) mgrid_file = 'mgrid_'//TRIM(proc_string)//'.nc'
CALL RESCALE_BOUNDARY ! Necssary for output file to have correct RBC/ZBS
CALL write_indata_namelist(iunit_out,ier)
CASE('test')
END SELECT
Expand Down
34 changes: 2 additions & 32 deletions VMEC2000/Sources/Input_Output/readin.f
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ SUBROUTINE readin(input_file, iseq_count, ier_flag, lscreen)
& NonZeroLen
REAL(dp), DIMENSION(:,:), POINTER ::
& rbcc, rbss, rbcs, rbsc, zbcs, zbsc, zbcc, zbss
REAL(dp) :: rtest, ztest, tzc, trc, delta, AVolume, AArea, TArea,
& AR00
REAL(dp) :: rtest, ztest, tzc, trc, delta
REAL(dp), ALLOCATABLE :: temp(:)
CHARACTER(LEN=100) :: line, line2
CHARACTER(LEN=1) :: ch1, ch2
Expand Down Expand Up @@ -268,36 +267,7 @@ SUBROUTINE readin(input_file, iseq_count, ier_flag, lscreen)
!
! Rescale the equilibria if asked
!
IF (tvolume .gt. 0.0) THEN
CALL INDATA_VOLUME(AVolume)
IF (lvolume_rfix) THEN
CALL INDATA_AREA(AArea)
AR00 = AVolume/(twopi * AArea)
TArea = TVolume/(twopi * AR00)
raxis_cc = rbc(0:ntord,0)
zaxis_cs = zbs(0:ntord,0)
rbc = rbc * (Tarea / Aarea) ** (1.0/2.0)
zbs = zbs * (Tarea / Aarea) ** (1.0/2.0)
rbc(0:ntord,0) = raxis_cc(0:ntord)
zbs(0:ntord,0) = zaxis_cs(0:ntord)
IF (lasym) THEN
raxis_cs = rbs(0:ntord,0)
zaxis_cc = zbc(0:ntord,0)
rbs = rbs * (Tarea / Aarea) ** (1.0/2.0)
zbc = zbc * (Tarea / Aarea) ** (1.0/2.0)
rbs(0:ntord,0) = raxis_cs(0:ntord)
zbc(0:ntord,0) = zaxis_cc(0:ntord)
END IF
ELSE
rbc = rbc * (tvolume / AVolume) ** (1.0/3.0)
zbs = zbs * (tvolume / AVolume) ** (1.0/3.0)
IF (lasym) THEN
rbs = rbs * (tvolume / AVolume) ** (1.0/3.0)
zbc = zbc * (tvolume / AVolume) ** (1.0/3.0)
END IF
ENDIF
CALL INIT_AXIS_MIDPOINT
END IF
CALL RESCALE_BOUNDARY
!
! Open output files here, print out heading to threed1 file
!
Expand Down

0 comments on commit 8b80d1e

Please sign in to comment.