2023年度Q2 計算材料学特論 (資料: 英語+日本語版)
Computational Materials Science 2023 Q2

数値解析に関する講義資料・pythonプログラム (神谷担当分)
Lecture materials on numerical analysis (by Kamiya)

講義で使うプレゼン資料は、Other related programsの下にあります
Lecture presentation slides will be found after the python tips section.

Update News:

python ノート

Other related programs

pythonプログラミングを始める前に
Getting Started with python
 本講義では、pythonは必須ではありませんが、
アルゴリズムの理解と今後の研究に役に立ちますので、
余裕のある人は試してみてください。
  python is not a requirement for this class,
but it will help your understanding about the algorisms to be learned and also assist your future research.
pythonのインストール方法
Install python
28/05/2019 9:31 created 
共通して使うpythonプログラム:
Common python programs:
  • plotcsv1.py
    Plot a single graph from (x, y1, y2, ...) data in a CSV file.
    What you learn: Graph plot using the matplotlib module, read data from a CSV file using the csv module.
    Usage: python plotcsv1.py csv_file_path
    How to use: download plotcsv1.py and data.csv, run 'python plotcsv1.py data.csv'.
  • plotcsv_mult.py
    Plot tile-arrayed graphs from (x, y1, y2, ...) data in a CSV file.
    What you learn: Graph plot using the matplotlib module, read data from a CSV file using the csv module.
    Usage: python plotcsv_mult.py csv_file_path
    How to use: download plotcsv_mult.py and diff_order.csv , run 'python plotcsv_mult.py diff_order.csv'.
  • plot_realtimeupdate.py
    An example of dynamic graph where graph is updated real-time.
    What you learn: Real-time update of graph using matplotlib.
    Usage: python plot_realtimeupdate.py
    How to use: download plot_realtimeupdate.py'.
 

 

講義予定日
Date

講義内容
Contents

講義資料
Lecture materials

掲載履歴
Upload / update history

June 13, 2023 コンピュータの基礎
Fundamental of computer
誤差
Sources of errors
20230613ComputerAndErorrSouorces.zip June 13, 9:07 uploaded
  python programs:
Level **: Convert base of given integer
  
Program:
download base.py (Source code)
   Algorisms / Python modules: sys to get start-up variables
   Usage: python base.py value(integer) base_source base_target
   ex: python base.py 101101 2 10
        Convert 1011012 to base 10.
   Output: to display
        1st step: Convert value to base 10
        2nd step: Convert the base 10 value to base_target
   What you learn: while, if, % (residual), ** (power), print and format

Level *: Roundoff error from summing up small values (compare different precisions):  
   It compares the roundoff errors for different precision floating point types using ndarray of numpy module.
   Program: download sum_error.py (Source code) or sum_error-plt.py (Source code)
   Algorisms / Python modules: numpy
   Usage: python sum_error.py
   Output: to display and sum_error.csv
   What you learn: for, if, write to csv, numpy ndarray with specified FP precision

Level *: Roundoff error from summing up small values:  
   Show roundoff errors for given increment h and iteration number n.
   Program: download sum.py (Source code)
   Algorisms / Python modules: none
   Usage: python sum.py h n
   Ex: python sum.py 0.1 20
      Add 0.1 incrementally for 20 times and show each result.
   Output: to display
   What you learn: nothing new

Level *: Information buried:  
   Show the result of exp(-40) by Taylor expansion to show the  error of information buried.
   Program: download information_buried.py (Source code)
   Algorisms / Python modules: none
   Usage: python information_buried.py
   Output: to display
   What you learn: nothing new

 

June 16, 2023 数値微分
Numerical differentiation
数値積分
Numerical integration
20230616DifferentialIntegration.zip June 15, 12:48 uploaded
  python programs: Numerical differentiation
Level *: Effect of x mesh h on numerical differentiation using two-point forward difference method:
 
   It compares the differentiation errors for different x mesh h for two-point forward difference method,
   df / dx ~ (f(x+h) - f(x)) / h.
   Program: download diff_h.py (Source code)
   Algorisms / Python modules: none
   Usage: python diff_h.py
   Output: to display and diff_h.csv.
   What you learn: function definition

Level *: Effect of different approximations on numerical differentiation: 
   It compares the differentiation errors for two- to seven-point difference approximations.
   Program: Download diff_order.py ( Source code)
   Algorisms / Python modules: none
   Usage: python diff_order.py
   Output: to display, diff_order.csv, and graph
   Visualization: implemented in the python script
   What you learn: how to plot graph using matplotlib 

Level *: Effect of different approximations on numerical differentiation with random noise data: 
   It compares the differentiation errors for two- to seven-point difference approximations.
   Program: download diff_order_noise.py (Source code)
   Algorisms / Python modules: two- to seven-point difference approximations
   Usage: python diff_order_noise.py
   Output: to display, diff_order_noise.csv, and graph
   What you learn: random functions in random module

Level ***:  Richardson extrapolation differentiation: 
   Program: download diff_richardson.py (Source code)
   Algorisms / Python modules: Richardson extrapolation
   Usage: python diff_richardson.py
   Output: to display.
   What you learn: for ~ break  
 

python programs: Numerical integration
Level **:
  Effect of different approximations on numerical integration: 
   It compares the integration errors for different approximations
   Program: download integ_order.py (Source code)
   Algorisms / Python modules: Rieman sum, trapezoid method, Simpson method, Bode method
   Usage: python integ_order.py
   Output: to display and integ_order.csv
   What you learn:  

Level ***: Numerical integration by Gauss-Legendre formula: 
   Program: download integ_gauss_legendre.py (Source code)
   Algorisms / Python modules: Gauss-Legendre formula
   Usage: python integ_gauss_legendre.py
   Output: to display.
   What you learn:  

Level ***:  Numerical integration by Romberg formula: 
   Download integ_romberg.py and run 'python integ_romberg.py'.
     Output: to display.
     What you learn:  

Level ****:  Numerical integration by variable conversion type formula: I.M.T. formula: 
   Download integ_imt.py and integ_gauss_legendre.py and run 'python integ_imt.py'.
     Output: to display.
     What you learn: use users' module (integ_gauss_legendre.py)

Level ****:  Numerical integration by variable conversion type formula:  Double Exponential function formula: 
   Download integ_doubleexp.py and run 'python integ_doubleexp.py'.
     Output: to display.
     What you learn:  

Level **: Effect of different h and approximations on numerical integration
   It compares the integration errors for Rieman, trapezoid, Simpson, and Bode methods with different h
   Program: download integ_order_h.py (Source code)
   Algorisms / Python modules: numerical integration (Rieman sum, trapezoid formula, Simpson formula, Bode formula)
   Usage: python integ_order_h.py xmin xmax nhscan func_type
                    func_type: [lorentz|gauss|exp]
                    nhscan: Number of division for the integration range is 2^nhscan (default: 18)
   Ex: python integ_order_h.py 0 1 18 gauss
              Check accuracy is improved in order of Rieman sum, trapezoid, Simpson and Bode formula for usual cases
        python integ_order_h.py -1 1 18 gauss
              Check Rieman sum is equal to trapezoid formula for symmetric integration
        python integ_order_h.py -5 5 12 gauss
              Check Rieman/trapezoid formula are better than the Simpson and Bode forumula 
   Output: to display and graph
   Visualization: implemented in the python script
   What you learn:  

Level **: Calculate Debye function
   Plot Debye function with given Debye temperature and temprature range
   Program: download debye_function.py (Source code)
 Show usage: python debye_function.py
 Usage: python debye_function.py Debye_T Tmin Tmax Tstep
 Ex.: python debye_funciton.py 300 0 500 10
   Debye temperature 300K, temperature range 0 - 500 K, 10 K step

Level **: Calculate electron density in metal based on the free electron model
  
It calculate the electron density in metal using the density of states function N(E) and the Fermi-Dirac distribution function f(E) by integrating N(E)f(e). Different integration functions in scipy, integrate.quad() and integrate.romberg() are compared. 
   Program: download N-integration-metal.py  (Source code)
   Algorisms / Python modules: Numerical integration (adaptive integration scipy.integrate.quad(), Romberg integration scipy.integrate.romberg()) 
   Usage: python N-integration-metal.py T EF
  
Ex.:
python N-integration-metal.py 300 5.0
         At 300K, EF = 5.0 eV, integrate with the specified relative accuration of 10-8 for integrate.quad() function. Compare the execution time for 300 cycles integrations.
     Integration range (1): E = 0 ~ EF + 6kBT
     Integration range (2): E = 0 ~ EF - 6kBT
     Integration range (3): E = EF - 6kBT ~ EF + 6kBT
       
Integration range (1) = Integration range (1) + Integration range (2)
 

 

June 20, 2023 微分方程式
Differential equation
分子動力学法
Molecular dynamics
20230618Diffeq.zip June 18, 7:57 uploaded
 

python programs: Solve a first-order differential equation
Level ***: Euler and Heun formula:
 
   Solve differential equation, dx(t) / dt = -x2
   Program: download diffeq_euler_heun.py (Source code)
   Algorisms / Python modules: Euler formula and Heun formula
   Usage: python diffeq_euler_heun.py x0 dt nt
   Output: to display, diffeq_euler_heun.csv, and graph
   Visualization: implemented in the python script
   What you learn:  

  Simpson formula: 
   Download diffeq_simpson.py and run 'python diffeq_simpson.py'.
     Output: to display.
     What you learn:  

  Three-stage third-order Runge-Kutta formula: 
   Download diffeq_rungekutta.py and run 'python diffeq_rungekutta.py'.
     Output: to display.
     What you learn:  

  Four-stage fourth-order Runge-Kutta formula: 
   Download diffeq_rungekutta4.py and run 'python diffeq_rungekutta4.py'.
     Output: to display.
     What you learn:  

 

python programs: Solve a second-order differential equation
  Euler formula: 
   Download diffeq2nd_euler.py and run 'python diffeq2nd_euler.py'.
     Output: to display and diffeq2nd_euler.csv.
     Visualization: download plotcsv1.py and run 'python plotcsv1.py diffeq2nd_euler.csv'.
     What you learn:  

  Heun formula: 
   Download diffeq2nd_heun.py and run 'python diffeq2nd_heun.py'.
     Output: to display and diffeq2nd_heun.csv.
     Visualization: download plotcsv1.py and run 'python plotcsv1.py diffeq2nd_heun.csv'.
     What you learn:  

  Verlet formula: 
   Download diffeq2nd_verlet.py and run 'python diffeq2nd_verlet.py'.
     Output: to display and diffeq2nd_verlet.csv.
     Visualization: download plotcsv1.py and run 'python plotcsv1.py diffeq2nd_verlet.csv'.
     What you learn:  

 

python programs: Solve simultaneous second-order differential equations (連立2次微分方程式)
  Euler formula: 
   Download diffeq2nd_2d_euler.py and run 'python diffeq2nd_2d_euler.py'.
     Output: to display and diffeq2nd_2d_euler.csv.
     Visualization: download plotcsv1.py and run 'python plotcsv1.py diffeq2nd_2d_euler.csv'.
     What you learn: function that returns two values  

  Verlet formula: 
   Download diffeq2nd_2d_verlet.py and run 'python diffeq2nd_2d_verlet.py'.
     Output: to display and diffeq2nd_2d_verlet.csv.
     Visualization: download plotcsv1.py and run 'python plotcsv1.py diffeq2nd_2d_verlet.csv'.
     What you learn:

Level ******: Planet simulator:
 
  Simulate motions of the planets in the solar system by the Euler or the Verlet formula
   Program: download diffeq2nd_planet.py (Source code)
   Input file(s): Planets database planet_db.csv
   Algorisms / Python modules: Euler formula and Heun formula
   Usage: python diffeq2nd_planet.py solver dt nt fplot
                    solver: 'Euler' or 'Verlet'
                    dt: time step in day
                    nt: number of steps
                    fplot: flag to plot graph (1: default) or not to plot (0)
   Ex: python diffeq2nd_planet.py Euler 0.5 5000 1
   Output: to display, diffeq2nd_planet_euler.csv and diffeq2nd_planet_euler_conservation.csv, and graph
   Visualization: integrated
   What you learn: realtime update of graph using matplotlib, min(), max(), sys.arg to change the solver
 

python programs: Smoothing, Convolution
Level ***:
 Simple moving average and polynomial fit method: 
   Program: download smoothing.py (Source code)
   Input file(s): xrd.csv
   Usage: python smoothing.py
   Output: to display, smoothing-*.csv, and graph
   Visualization: integrated. 
              Or download plotcsv1.py and run, e.g., 'python plotcsv1.py smoothing-simple-3.csv'.

Level ***: Convolution with Gauss function:
   Program: convolution.py (Source code)
   Input file(s): dos.csv
   Usage: python convolution.py
   Output: to display, convolution.csv, and graph
   Visualization: integrated.  
              Or download plotcsv1.py and run, e.g., 'python plotcsv1.py convolution.csv'.
     What you learn:  

Level *****: Convolution/Deconvolution with Gauss function:
  
Deconvolution by scipy.signal.deconvolve(), fft, the Jacobi method, and the Gauss-Seidel method.
   Program:  deconvolution.py (Source code)       
   Input file(s): pes.csv
   Show usage: python deconvolution.py
   Output: to display and graph
   Visualization: integrated
   What you learn: scipy.signal.convolve() and scipy.signal.deconvolve().
        Deconvolution using FFT and iFFT.
   More details:
         Show usage: python deconvolution.py
           usage for convolve() and fft: 
                python deconvolution.py file mode convmode smoothmode xmin xmax Wa Grange kzero klin
                   mode = [convolve|fft]
                   convmode = ['|full|same], effective only for mode = 'convolve'
                   smoothmode = combination of [convolve|extend|average]
          ex.: python deconvolution.py SnSe-DOS.csv convolve same convolve+extend -4.5 2.0 0.12 2.0 1 5
                Deconvolute using scipy.signal.deconvolve() after extending the raw data with zeros and linear filter.
                The x range is from -4.5 to 2.0.
                Gaussian filter has the width of 12 and the 2.0 times of the width will be used.
                Note that the filter elements should have somewhat large values e.g. > 0.01 for scipy.signal.deconvolve()
          ex.: python deconvolution.py SnSe-DOS.csv fft full convolve+extend -4.5 2.0 0.12 2.0 5 5
                Deconvolute using fft-based deconvoluation after extending the raw data with zeros and linear filter.
                The x range is from -4.5 to 2.0.
                Gaussian filter has the width of 12 and the 2.0 times of the width will be used.
           usage for the Jacobi/Gauss-Seidel mehods:
                  python deconvolution.py file mode xmin xmax Wa dump nmaxiter eps nsmooth zeroc
                      mode = [gs|jacobi] 
                      gs=Gauss-Seidel method jacobi=Jacobi method
                       zeroc = [0|1] zero correction after a Jacobi/Gauss-Seidel cycle
         ex.: python deconvolution.py pes.csv gs -6.0 2.0 0.12 1.0 300 1.0e-4 15 0
 

 

June 23, 2023 補間
Interpolation
平滑化
Smoothing 
20230622InterporlateSmoothing.zip June 22, 12:17 uploaded
  python programs: Smoothing, Convolution
Level ***:
 Simple moving average and polynomial fit method: 
   Program: download smoothing.py (Source code)
   Input file(s): xrd.csv
   Usage: python smoothing.py
   Output: to display, smoothing-*.csv, and graph
   Visualization: integrated. 
              Or download plotcsv1.py and run, e.g., 'python plotcsv1.py smoothing-simple-3.csv'.

Level ***: Convolution with Gauss function:
   Program: convolution.py (Source code)
   Input file(s): dos.csv
   Usage: python convolution.py
   Output: to display, convolution.csv, and graph
   Visualization: integrated.  
              Or download plotcsv1.py and run, e.g., 'python plotcsv1.py convolution.csv'.
     What you learn:  

Level *****: Convolution/Deconvolution with Gauss function:
  
Deconvolution by scipy.signal.deconvolve(), fft, the Jacobi method, and the Gauss-Seidel method.
   Program:  deconvolution.py (Source code)       
   Input file(s): pes.csv
   Show usage: python deconvolution.py
   Output: to display and graph
   Visualization: integrated
   What you learn: scipy.signal.convolve() and scipy.signal.deconvolve().
        Deconvolution using FFT and iFFT.
   More details:
         Show usage: python deconvolution.py
           usage for convolve() and fft: 
                python deconvolution.py file mode convmode smoothmode xmin xmax Wa Grange kzero klin
                   mode = [convolve|fft]
                   convmode = ['|full|same], effective only for mode = 'convolve'
                   smoothmode = combination of [convolve|extend|average]
          ex.: python deconvolution.py SnSe-DOS.csv convolve same convolve+extend -4.5 2.0 0.12 2.0 1 5
                Deconvolute using scipy.signal.deconvolve() after extending the raw data with zeros and linear filter.
                The x range is from -4.5 to 2.0.
                Gaussian filter has the width of 12 and the 2.0 times of the width will be used.
                Note that the filter elements should have somewhat large values e.g. > 0.01 for scipy.signal.deconvolve()
          ex.: python deconvolution.py SnSe-DOS.csv fft full convolve+extend -4.5 2.0 0.12 2.0 5 5
                Deconvolute using fft-based deconvoluation after extending the raw data with zeros and linear filter.
                The x range is from -4.5 to 2.0.
                Gaussian filter has the width of 12 and the 2.0 times of the width will be used.
           usage for the Jacobi/Gauss-Seidel mehods:
                  python deconvolution.py file mode xmin xmax Wa dump nmaxiter eps nsmooth zeroc
                      mode = [gs|jacobi] 
                      gs=Gauss-Seidel method jacobi=Jacobi method
                       zeroc = [0|1] zero correction after a Jacobi/Gauss-Seidel cycle
         ex.: python deconvolution.py pes.csv gs -6.0 2.0 0.12 1.0 300 1.0e-4 15 0

 

 

June 27, 2022 線形最小二乗法
Linear least-squares method
20230627LSQEquationOptimize.zip uploaded June 24, 11:27
  python programs: linear LSQ
Level ***: Least-squares fitting for polynomial:
   Fit n-th order polynomial to scattered data by linear LSQ.
   Program: download  lsq-polynomial.py (Source code)
   Algorisms / Python modules: Linear LSQ for polynomial
   Usage: python lsq-polynomial.py norder
   Ex: python lsq-polynomial.py 3
   
   Fit to y = c0 + c1x + c2x2 + c3x3
   Output: to display, lsq-polynomial.csv, and graph
   Visualization: integrated
   What you learn: numpy.linalg.inv to get inverse matrix and solve simultaneous linear equations

Level ***: Least-squares fitting for general functions:
   Fit sin + cos function to scattered data by linear LSQ.
   Program: download lsq-general.py (Source code)
   Algorisms / Python modules: Linear LSQ for sin / cos functions
   Usage: python lsq-general.py nfunc
   Ex: python lsq-geneal.py 3
   
   Fit to y = c0 + c1sin(x) + c2cos(x)
   Output: to display, lsq-general.csv, and graph
   Visualization: implemented in the python script
   What you learn: numpy.linalg.inv to get inverse matrix and solve simultaneous linear equations

 

 

June 27, 2023
June 30, 2023

方程式の数値解法
Numerical solution of equation
最適化 (非線形最小二乗法)
Optimization (Nonlinear LSQ)

20230627LSQEquationOptimize.zip
20230630Optimization2.zip

June 30, 12:43 updated
June 30, 8:45 uploaded
June 24, 11:27 uploaded
  python programs: Solution of equation
Level **: Self-consistent method:
   An example to solve a simple equation, x = 0.5(-x3 + x2 - 2) by self-consistent manner.
   Program: download equation-selfconsistent.py (Source code)
   Usage: python equation-selfconsistent.py
   Output: to display.
   Visualization:  
   What you learn:  

Level **: Self-consistent method:
   Solve the I-V characteristic of a series circuit of a diode and a resister by self-consistent manner.
   Program: download equation-selfconsistent-diode.py
   Usage: python equation-selfconsistent-diode.py Vmin Vmax Vstep kmix
   Output: to display and graph
   Visualization: integrated 
   What you learn:  

Level ***: Newton-Raphson method:
   Program: download equation-newton-raphson.py (Source code)
   Usage: python equation-newton-raphson.py x0 dump tsleep
   Output: to display and graph
   Visualization:  
   What you learn:  

  Bisection method:
   Solve the Fermi level of semiconductor by bisection method.
   Download equation-bisection.py, and run 'python equation-bisection.py'.
     Output: to display.
     Visualization:  
     What you learn:  

  Brent's method:
   Solve the Fermi level of semiconductor by Brent's method.
   Download equation-brant.py, and run 'python equation-brent.py'.
     Output: to display.
     Visualization:  
     What you learn:  

Level ***: Calculation of EF for semiconductor by bisection method
   Program: download EF-bisection.py (Source code)
   Algorisms / Python modules: Bisection method
   Usage: python EF-bisection.py
   Output: to display.
   Visualization:  
   What you learn:  

Level ***: 金属のEFの温度依存性
   Program: download EF-T-metal.py (Source code)   
   説明: 金属のフェルミエネルギーの温度依存性を数値積分とNewton法を使って求める。
    初期値として 0 K の EF から始め、温度を上げながら、前回温度の EF(T) を次の初期値として使うことで、
    Newton法でも安定して計算できる。
  使用しているアルゴリズム: 数値積分 (多項式適合法 scipy.integrate.quad())
                  方程式の数値解法 (Newton法 scipy.optmize.newton())
  実行方法: python EF-T-metal.py 

Level ****: 半導体の統計物性の温度依存性
   Program: download EF-T-semiconductor.py (Source code)
   説明: 半導体のフェルミエネルギー、自由電子濃度、自由正孔濃度、イオン化アクセプター濃度、
           イオン化ドナー濃度の温度依存性を二分法を使って求める。非縮退近似を用い、
           ドナー・アクセプター準位の縮重は考慮していない。
     Newton法では EF の初期値がかなり真値に近くないと発散するので、
     価電子帯上端と伝導帯下端エネルギーを初期として二分法を使う。
  使用しているアルゴリズム: 方程式の数値解法 (二分法 main()関数中に組み込み) 
  Usage:
python EF-T-semiconductor.py EA NA ED ND Ec Nv Nc
  実行例: python EF-T-semiconductor.py 0.05 1.0e15 0.95 1.0e16 1.0 1.2e19 2.1e18
     Ec = 1.0 eV (= バンドギャップ)、EA = 0.05 eV, NA = 1015 cm-3, ED = 0.95 eV, ND = 1016 cm-3
  
    Nc = 1.2x1019 cm-3, Nv = 2.1x1018 cm-3 (バンドギャップを1.12 eVとすれば、ほぼ Si の物性値) 

Level *****: Solve multi-values equation: Calculate energy band diagram and wave functions by Kronig-Penney model
 
説明:
Kronig-Penneyモデルによる一次元バンド構造と波動関数
  Program:
Download kronig_penney.py ( Source code)
  使用しているアルゴリズム: Find multiple solutions by direct search and secant method
  Usage: python kronig_penney.py 
  Usage1: python kronig_penney.py (graph a bwidth bpot k Emin Emax nE) 
  Usage2: python kronig_penney.py (band a bwidth bpot nG kmin kmax nk) 
  Usage3: python kronig_penney.py (wf a bwidth bpot kw iLevel xwmin xwmax nxw)
  実行例1: python kronig_penney.py graph 5.4064 0.5 10.0 0.0 0.0 9.5 51 
  格子定数 5.4064 Å、ポテンシャル幅 0.5 Å、高さ 10.0 eVで、k = 0.0 についてのKronig-Penney方程式の
  残差 Δ を E = 0.0 ~ 9.5 eV の範囲を51分割してプロット。Δ = 0 のEが固有エネルギー。
  実行例2: python kronig_penney.py band 5.4064 0.5 10.0 -0.5 0.5 21
  格子定数 5.4064 Å、ポテンシャル幅 0.5 Å、高さ 10.0 eVで、k = [-0.5,0.5] の範囲を 21分割してバンド構造をプロットする。
  実行例3: python kronig_penney.py wf 5.4064 0.5 10.0 0.0 0 0.0 16.2192 101
  格子定数 5.4064 Å、ポテンシャル幅 0.5 Å、高さ 10.0 eVで、k = 0.0 における下から 0 番目の
  準位の波動関数をプロットする。波動関数は x = 0.0 ~ 16.2192 Å を 101 分割してプロットする。

 

python programs: Nonlinear optimization
  One parameter Newton-Raphson method:
   Minimize a target function with one parameter by Newton-Raphson method.
   Download optimize-newton-raphson1d.py, and run 'python optimize-newton-raphson1d.py'.
     Output: to display.
     Usage:  python optimize-steepdescent1d.py xini
     Visualization:  implemented in the python script
     What you learn:  

  Two parameters Newton-Raphson method with graphical visualization of convergence process:
   Minimize a target function with two parameters by Newton-Raphson method.
   Download optimize-newton-raphson2d.py, and run, e.g., 'python optimize-newton-raphson2d.py', and  'python optimize-newton-raphson2d.py -4.0 -4.0'.
     Output: to display and graph.
     Usage:  python optimize-newton-raphson2d.py xini yini
     Visualization:  implemented in the python script
     What you learn:  

  Two parameters Steepest Descent method with graphical visualization of convergence process:
   Download optimize-steepdescent2d.py, and run, e.g., 'python optimize-steepdescent2d.py' and 'python optimize-steepdescent2d.py -4.0 -4.0'.
     Output: to display and graph.
     Usage:  python optimize-steepdescent2d.py xini yini
     Visualization:  implemented in the python script
     What you learn:  

  Two parameters Steepest Descent & Conjugate Gradient methods + Line Search methods 
with graphical visualization of convergence process:
   Minimize a target function with two parameters by the SD method and several line search methods.
   Download optimize-sd-cg2d-linesearch.py, and run, e.g., 
       'python optimize-sd-cg2d-linesearch.py'
       'python optimize-sd-cg2d-linesearch.py -4.0 -4.0'
       'python optimize-sd-cg2d-linesearch.py 2 2 sd one ellipsoid'
       'python optimize-sd-cg2d-linesearch.py 2 2 cg golden ellipsoid'
     Output: to display and graph.
     Usage:  python optimize-sd-cg2d-linesearch.py xini yini algorism lsmode functype
                    algorism: optional, [sd|cg], default = 'sd'
                    lsmode: optional, [one|simple|exact|golden|armijo], default = 'simple'
                    functype: optional, '' or 'ellipsoid', default = ''
     Visualization:  implemented in the python script
     What you learn:  

  Two parameters Marquart mehod to solve a LSQ problem:
   Download lsq-marquart2d.py, and run 'python optimize-marquart2d.py'
     Output: to display.
     Visualization:  
     What you learn:  

 

python programs: Nonlinear optimization using scipy.optimize
  Optimization using the scipy.optimization module.
   
Download peakfit-scipy-minimize.py and tklib.py, and run 'python peakfit-scipy-minimize.py'.
     Output: to display and csv files, initial.csv, final.csv, and convergence.csv
     Visualization: implemented in the python script
     What you learn: scipy.optimize, matplotlib, csv

 

July 4, 2023 フーリエ変換
Fourier transform
行列
Matrix
応用 
Applications
20230703Summary.zip  July 4, 11:45 uploaded
  python programs: Fourier transformation (FT)
  Fourier transformation by efficient discrete FT (DFT), simple FT (DFT2), and numpy FFT:
   Compare execution time for different FT algorisms
   Download dft.py, and run 'python dft.py'.
     Output: to display
     Visualization:  
     What you learn: time, numpy ndarray, numpy fft  
python programs: Matrix
  Matrix operations using numpy/scipy.linalg:
   Download matrix.py, and run 'python matrix.py'.
     Output: to display 
     Visualization:  
     What you learn: numpy.linalg, scipy.linalg  
python programs: applications (Under construction)

結晶構造関係プログラム
資料:
Crystal.pdf 
* レベル★★ 結晶構造・ベクトル解析基本ライブライブラリィ tkcrystalbase.py (プログラムコード)
  説明:
他のpythonプログラムからimportして使用する。
* レベル★★ 単位格子・逆格子描画  crystal_draw_cell.py (プログラムコード・実行結果)
    実行方法: python crystal_draw_cell.py
* レベル★★ 単位格子変換・描画     crystal_convert_cell.py (プログラムコード・実行結果)
    実行方法:
python crystal_convert_cell.py crystal_name conversion_mode kRatom
   
実行例:
python crystal_convert_cell.py FCC FCCPrim
* レベル★★ 原子間距離      crystal_distance.py     (プログラムコード)
    実行方法:
python crystal_distance.py
* レベル★★ Bragg角度    crystal_XRD.py    (プログラムコード)
    実行方法:
python crystal_XRD.py
* レベル★★★ Madelung potentialの計算   crystal_MP_Ewald.py  ( プログラムコード)
    実行方法:
python crystal_MP_Ewald.py

 

 


2018年度 計算材料科学特論 (資料:日本語版)

神谷 講義資料

2018/6/12 コンピュータの原理 20180611SlideDay1Ver1.pdf 2018/6/11 10:57 公開
2018/6/16 数値微分・積分、常微分方程式 20180614slideday2ver1.pdf 2018/6/14 14:16 公開
2018/6/19 常微分方程式、分子動力学法、補間、平滑化 20180619slideday3ver2.pdf 2018/6/18 12:00 公開
2018/6/19 12:31 Ver.2
2018/6/22 平滑化、線形最小自乗、最適化、方程式の数値解 20180620slideday4ver1.pdf 2018/6/20 17:05 公開
2018/6/26 非線形最小自乗、Fourier変換 (Monte Carlo法、行列は省く) 20180626slideday5ver2.pdf 2018/6/25 公開
2018/6/26 11:07 Ver.2