class:phy3026

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
class:phy3026 [2018/08/13 18:19] – created minerva1993class:phy3026 [2023/03/06 13:44] (current) – external edit 127.0.0.1
Line 1: Line 1:
-=====PHY3026Computational Physics=====+=====PHY3026 Computational Physics: Fall 2019=====
  
 +===Class materials in git===
 +<code>
 +git clone https://github.com/monttj/computational-physics
 +</code>
 +
 +===Prepare your computing environment===
 +Choose one of following methods to connect to use ssh and the other linux commands
 +**Use Mac OS or Linux**
 +You can directly access to the server with native bash (terminal) in Mac os or Linux.
 +You can also install Linux (usually Ubuntu) to virtual box ({{https://www.virtualbox.org/|link}} but the performance will be largely degraded since the os will share resources with native Windows
 +
 +**Install ubuntu via Microsoft appstore**
 +This part is written based on Windows 10 1903 update.
 +Open Control Panel (제어판) - Programs and Features (프로그램 및 기능) -  Turn Windows features on or off (Windows 기능 끄키/켜기) - activate 'Windows Subsystem for Linux' (Linux용 Windows 하위시스템 항목 활성화) - 재부팅
 +
 +Open Microsoft appstore, search for 'Ubuntu' - install Ubuntu 18.04
 +
 +Type username and root password. If you failed to correctly verify password (비밀번호를 두 번 입력해야하는데 실수로 서로 다르게 입력하여 계정 생성에 실패할경우), go to Settings (설정) - Apps & features (앱 및 기능) - Ubuntu 18.04 LTS (Ubuntu 18.04 LTS 클릭) - Advanced options - Reset)
 +
 +In terminal, you can use linux commands like ssh, ls, cd.
 +
 +*Optional: change ubuntu mirror and update
 +In terminal,
 +<code>
 +sudo vi /etc/apt/sources.list
 +:%s/archive.ubuntu.com/mirror.kakao.com/    (콜론 포함하여 vi기능에서 찾아바꾸기임)
 +('kr.archive.ubuntu.com'부분은 사람마다 다를 수 있으니 적당히 바꾸면 됨)
 +:wq                                            (저장하고 나오기)
 +sudo apt-get update
 +sudo apt-get upgrade                           (설치하시겠습니까? [Y/n]등의 메시지 나오면 Y 선택하여 설치)
 +sudo apt install python2.7                     (python 2.7 설치. 기본은 3.5)
 +sudo pip install numpy                         (예를 들어 numpy 설치)
 +</code>
 +
 +Next, you need to install Xming {{https://xming.ko.softonic.com/|link}} to forward graphic output from server to your local computer. Then you add following lines in your bashrc
 +<code>
 +vi ~/.bashrc
 +GG                (vi 명령어, 맨 아래로 이동하기)
 +i                 (vi 쓰기모드)
 +export DISPLAY=0:0
 +esc key           (쓰기모드에서 나가기)
 +:wq               (저장하고 파일 닫기)
 +source ~/.bashrc  (변경사항 적용)
 +</code>
 +
 +
 +**Install MobaXterm**
 +<code>
 +https://mobaxterm.mobatek.net/download.html
 +</code>
 +{{ :class:mobaxterm_portable_v12.1.zip |MobaXterm}}
 +
 +**Connect to server**
 +
 +Ask to tutor to create accounts for students. Start local terminal in mobaxterm.
 +<code>
 +ssh -X YOURID@210.117.210.IP
 +</code>
 +
 +**Jupyter notebook**
 +
 +To write and excute python code in your local browser, you need to create ssh tunnel to server. First, make sure you are using unique port number for tunnel. Follow the lines in the server.
 +<code>
 +##DO THIS ONLY AT THE FIRST TIME##
 +jupyter notebook --generate-config
 +vi /home/YOURID/.jupyter/jupyter_notebook_config.py
 +##DO THIS ONLY AT THE FIRST TIME##
 +</code>
 +
 +Then you can excute jupyter in server.
 +<code>
 +jupyter-notebook --no-browser
 +</code>
 +
 +You can check your port number in ''c.NotebookApp.port = 8888''. Now, create tunnel in your ''LOCAL(in desktop)'' terminal (not in server!).
 +<code>
 +ssh -f -N -L localhost:9XXX:localhost:9XXX YOURID@210.117.210.XX
 +</code>
 +
 +The address to jupyter notebook will appear in the terminal. Copy & paste into local internet browser.
 +
 +*Run ''.py'' in jupyter notebook*
 +<code>
 +%run some_code.py
 +</code>
 +
 +*Disable ssh tunnel*
 +
 +This is optional. But it can be required if you are using your own laptop without logout/restart, whatever. Find pid with ''ssh -p XXX....'' (which is ssh tunnel command you wrote in terminal), then quit it.
 +<code>
 +ps -elf | grep ssh
 +kill -9 <PID>
 +</code>
  • class/phy3026.1534151994.txt.gz
  • Last modified: 2023/03/06 13:44
  • (external edit)