コード例 #1
0
p_mass = 1.6726e-24
ev = 1.6022e-12

bmod_ref = 5.0e4
Z_charge = 2
m_mass = 4
E_kin = 3.5e6
trace_time = 1.0e-2
# rbig=rlarm*bmod00
# dphi=2.d0*pi/(L1i*npoiper)

v0 = np.sqrt(2.0*E_kin*ev/(m_mass*p_mass))    # alpha particle velocity, cm/s
rlarm = v0*m_mass*p_mass*c/(Z_charge*e_charge*bmod_ref)  # reference gyroradius
tau = trace_time*v0

libneo_orb = fortran_library('simple')

neo_orb = fortran_module(libneo_orb, 'neo_orb_global')
neo_orb.fdef("""  
  subroutine init_field(ans_s, ans_tp, amultharm, aintegmode)
    integer :: ans_s, ans_tp, amultharm, aintegmode
  end
  
  subroutine init_params(Z_charge, m_mass, E_kin, adtau, adtaumax, arelerr)
    integer :: Z_charge, m_mass
    double precision :: E_kin, adtau, adtaumax
    double precision :: arelerr
  end
  
  subroutine init_integrator(z0)
    double precision, dimension(:), intent(in) :: z0
コード例 #2
0
ファイル: bench_interface.py プロジェクト: itpplasma/SIMPLE
"""
Created: Tue Aug 20 15:07:28 2019
@author: Christopher Albert <*****@*****.**>
"""

import numpy as np
from fffi import fortran_library, fortran_module

libneo_orb = fortran_library('neo_orb', path='../lib')

bench = fortran_module(libneo_orb, 'neo_orb_bench')
bench.fdef("""  
    integer :: npoiper2
    double precision :: rbig, dtau, dtaumax
    
    integer :: nt
    
    double precision :: starttime, endtime
    
    
    logical :: multi
    logical :: quasi
    logical :: tok
    integer :: integ_mode
    integer :: nlag
    integer :: nplagr_invar
    integer :: ncut
    
    double precision :: taub
    double precision :: rtol
    
コード例 #3
0
"""
Created: Tue Aug 20 15:07:28 2019
@author: Christopher Albert <*****@*****.**>
"""

import numpy as np
from fffi import fortran_library, fortran_module

libneo_orb = fortran_library('neo_orb',
                             path='/u/calbert/build/NEO-ORB',
                             compiler={
                                 'name': 'ifort',
                                 'version': '18.0.3'
                             })

neoorb = fortran_module(libneo_orb, 'neo_orb_global')
neoorb.fdef("""
  subroutine init_field(ans_s, ans_tp, amultharm, aintegmode)
    integer, intent(in) :: ans_s, ans_tp, amultharm, aintegmode
  end
""")

libneo_orb.compile()
neoorb.load()
コード例 #4
0
from fffi import fortran_library, fortran_module

libneo_orb = fortran_library('simple',
                             compiler={
                                 'name': 'gfortran',
                                 'version': 9
                             })
# compiler={'name': 'ifort', 'version': 18})

neo_orb = fortran_module(libneo_orb, 'neo_orb_global')
neo_orb.fdef("""
  subroutine init_field(ans_s, ans_tp, amultharm, aintegmode)
    integer :: ans_s, ans_tp, amultharm, aintegmode
  end

  subroutine init_params(Z_charge, m_mass, E_kin, adtau, adtaumax, arelerr)
    integer :: Z_charge, m_mass
    double precision :: E_kin, adtau, adtaumax
    double precision :: arelerr
  end

  subroutine init_integrator(z0)
    double precision, dimension(:), intent(in) :: z0
  end

  subroutine timestep_z(z, ierr)
    double precision, dimension(:) :: z
    integer :: ierr
  end

  subroutine timestep_sympl_z(z, ierr)