数値計算法I - 九州工業大学

Download Report

Transcript 数値計算法I - 九州工業大学

数値計算法
第13回
連立微分方程式応用とJAVA
2006年度
九州工業大学工学部電気電子工学コース用講義資料
講師:趙孟佑
[email protected]
1
プログラミング言語
• 多用途
–
–
–
–
–
–
アセンブリ
Basic
Fortran
C
JAVA
その他無数
• 機能限定でもGUI(Graphical User Interface形式)
– Excell
– Mathematica
– Labview
2
プログラミングに必要なもの
•
•
•
•
•
•
•
•
•
•
整数、実数、文字列をデータとして扱う
四則演算(+-÷×)
数学関数(sin,cos,tan,exp,sqrt,----)
配列の定義
繰り返し計算(Do loop)
分岐(if文)
データ入力
データ出力
サブルーチン
これらの機能さえあれば、大抵のことはできる
3
Fortran
• FORmula TRANslating systemの略
• 1954年にIBMで誕生
• 初期(60年代)のコンピュータの需要
– 数式を単純に訳すことが最優先
– 簡単に出力を出せる write(6,*)
• 大型計算機で使われていた
– 大型科学技術計算の主流(80年頃迄)
– パソコン以上のコンピュータではメジャー
– UNIXではC言語が主流に
• 自分でプログラム作って走らせる人が多い
• 他人が使うプログラムにはあまり使われない
– GUIが貧弱
– 構造化に適していない(と言われる)
4
JAVA
• 1995年 Sun Microsystems社が発表
• 1996年 Netscape Navigator2.0でサポート開
始
• インターネットの拡大と同時に急速に普及
する
– Webブラウザで稼働するプログラムを簡単に作
れる
– コンパイラ(開発環境)が無料
5
JAVAの特徴
• OSに依存しない
– Windows,Mac,Linux,UNIXで走る
– 携帯電話でも走る
• グラフィック機能
– 簡単にグラフィックを多用したプログラム(アニメー
ション含む)を作成可能
• プログラムが簡単(Cに比べれば)
• ネットワーク機能
– 他のマシンにアクセスしたりするコマンドも既に用意
されている
• オブジェクト指向
– プログラムを細分化・モジュール化することで、コー
ドの開発を効率化
– 共同作業向き
6
JAVAの走らせ方
• アプレット
– Webブラウザで実行
– インターネットを介してプログラム配信が可能
– ファイルの入出力は制限される(当然)
• アプリケーション
– 普通のプログラムと同じ
7
JAVAの例
/* Application program */
public class Sum{
public static void main( String[] args){
float[] a= {1F, 2F, 3F, 4F, 5F, 6F, 7F, 8F, 9F, 10F};
float s = 0.0F;
for(int i=0; i<a.length; i++) s += a[i];
float b = s/(float)a.length;
System.out.println("s="+s+", average="+b);
}
}
8
JAVAの例
JAVA
/* Application program */
public class Sum{
public static void main( String[] args){
float[] a= {1F, 2F, 3F, 4F, 5F, 6F, 7F, 8F, 9F, 10F};
float s = 0.0F;
for(int i=0; i<a.length; i++) s += a[i];
float b = s/(float)a.length;
System.out.println("s="+s+", average="+b);
}
}
ファイル名はSum.javaにする
Fortran
parameter(nmax=10)
dimension a(nmax)
a(1)=1
a(2)=2
a(3)=3
a(4)=4
a(5)=5
a(6)=6
a(7)=7
a(8)=8
a(9)=9
a(10)=10
s=0.0
do i=1,10
s=s+a(i)
end do
b=s/nmax
write(6,*)' s=',s,' average=',b
stop
end
9
JAVAの走らせ方
• コンパイルするには
javac Sum.java
• うまくいくとSum.classというファイルができる。
• 実行するには
java Sum
• 結果が表示される
s=55.0, average=5.5
• Fortranでは
f77 -o sum.out sum.f
sum.out
s= 55.0000 average= 5.50000
10
アプレット
アプレット
/* Applet program */
//<applet code="SumAvg" width="300" height="100"></applet>
import java.applet.Applet;
import java.awt.*;
アプリケーション
/* Application program */
public class Sum{
public class SumAvg extends Applet{
public static void main( String[] args){
float[] a= {1F, 2F, 3F, 4F, 5F, 6F, 7F, 8F, 9F,
10F};
float s = 0.0F;
for(int i=0; i<a.length; i++) s += a[i];
public void init(){
setBackground( Color.white );
}
public void paint( Graphics g ){
float[] a = {1F, 2F, 3F, 4F, 5F, 6F, 7F, 8F, 9F, 10F};
float s = 0.0F;
for(int i=0; i<a.length; i++) s += a[i];
float b = s/(float)a.length;
g.drawString("s="+s+", average="+b, 30, 30);
}
float b = s/(float)a.length;
System.out.println("s="+s+",
average="+b);
}
}
}
11
アプレットの走らせ方
• まずコンパイルする
– javac SumAvg.java
• htmlファイルを作る。ファイルの中身は
<applet code="SumAvg" width="300" height="100"></applet>
の一行だけ。これをSumAvg.htmlという名前で保存する。必
ず.htmlという拡張子を付ける
• アプレットビューアを使う
– appletviewer SumAvg.html
• またはWebブラウザ(Internete ExplorerでもNetscapeでも何
でもよい)のファイルメニューからSumAvg.htmlを開く
12
アプレットの特徴
• 簡単にグラフィックプログラ
ムが作成可能
• Webサーバーに置けば、誰に
でもプログラムを渡せる
/* Applet program */
import java.applet.Applet;
import java.awt.*;
public class Graphic extends Applet{
public void init(){
setBackground( Color.white );
}
public void paint( Graphics g ){
g.setColor(Color.red);
g.drawString(" Hello", 150, 30);
g.setColor(Color.green);
g.drawLine(40,40,80,80);
g.setColor(Color.black);
g.drawRect(90,90,120,120);
g.setColor(Color.blue);
g.drawOval(20,20,30,30);
}
}
13
JAVA開発環境のインストール
• 生協でLinux付きのパソコンを買った人
– 多分そのまま入っています
• Windowsを買った人
– http://java.sun.com/j2se/1.5.0/ja/download.html
からダウンロードする
• Macの人
– Developerを入れる
– http://developer.apple.com/java/download/ からダ
ウンロードする
14
参考書
• Javaで学ぶシミュレーションの基礎
– 峯村吉泰 森北出版 2600円
• Javaによる図形処理入門
– 山本芳人 工学図書 2200円
• JavaプログラミングBlack Book 2nd Edition
– スティーブン ホルツナ インプレス社
• その他JAVAの参考書は無数にあります
15
連立微分方程式の応用
衛星帯電解析
16
What is spacecraft charging?
http://download.computers.yahoo.co.jp/download/jcnland/clip/season/newyear/engimono/051101017.html
• Satellite is electrically floating in space
• No ground (earth) in space
• Plasma serves as the reference of electrical potential
17
What is plasma
Plasma
electron(-) and ion(+)
80km
O+
Solar UV
Earth
O
e
• Space is filled with plasma (ions and electrons)
• Electrical conductivity at LEO is similar to sea water (~0.1Ω•m) 18
Spacecraft and plasma
e +
+
+
+
+ e +
e
e
e
e + e
e
+ +
e +
+
e
e
e
+
e+
+ e
e
e e +
+ e +
e
+
e +
e e
e
e
+
+ +
e
+
e +
+ e +e
e +
e + e
e e
http://jda.jaxa.jp/jda/p4_j.php?f_id=6654&mode=level&time=N&genre=4&category=4020
•
•
•
•
Spacecraft is floating in a sea of charged particles (plasma)
Spacecraft collects electrons and ions
It acquires electrical charge (either + or -)
19
Spacecraft has a potential with respect to the plasma
Why is spacecraft charging important?
• Spacecraft surface
– Made of insulator and conductor
– Conductor
• Connected to spacecraft body (metal)
• Same potential
– Insulator
• Possible to have different potentials
• If the potential difference is large
– Discharge (arcing)
solar array coverglass (insulator)20
Why is spacecraft charging important?
QuickTimeý Dz
QuickDraw êLí£ÉvÉçÉOÉâÉÄ
ǙDZÇÃÉsÉNÉ`ÉÉǾå©ÇÈǞǽDžÇÕïKóvÇ­ Ç•
ÅB
Discharge on solar panel in ground experiment
• Discharge on spacecraft
– Sometimes fatal to spacecraft operation
21
Why is spacecraft charging important?
41m
www.spacedaily.com/ news/solarcell-02l
http://www.boeing.com/defense-space/space/bss/factsheets/702
Galaxy3C (2002)
• Recent GEO telecom satellites
– Large size and high power
– Operate at high (>100V) voltage
– Single arc may be fatal to the entire satellite operation
22
How is spacecraft is charged
i
i
e
e
i
e
e i
i
e
i i
e
e
i
e
i
e i
i
e
e
i
i
i
e
e
i
i
e e i
e
e
i
e i
i
e
e i e
i e i
A conducting sphere in plasma
Electrons and ions collide with the sphere and charge it
At the steady state
Flux of negative charge = Flux of positive charge
23
Current sources to a spacecraft
24
If a spacecraft is modeled as a conducting sphere
Incident ions
Ii ( )
+
Electron-induced
secondary electrons
Ise ( )
Incident
electrons Ie ( )
-
-
Ion-induced secondary
electrons
Isi ( )
Photo-electrons
I ph ( )
Back-scattered
electrons Ibe ( )
Spacecraft potential  is determined to satisfy
Inet  Ii ( )  Ie ( )  Ise ( )  Isi ( )  I ph ( )  Ibe ( )  0
25
3
Dominant terms
• Spacecraft potential is determined mostly by
– Photo-electrons
– Ambient electrons and their secondaries
– Ambient ions
26
The surface potential d at the steady state is determined by jnet=0
jnet  ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
27
Total current (A) to spacecraft
I net  Ii (sc )  I e (sc )  I se (sc )  I si (sc )  I ph (sc )  Ibe (sc )
depends on spacecraft body potential sc
Current density (A/m2) to insulator surface
jnet  ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
depends on local insulator surface potential s
Body potential sc ≠ Insulator potential d
During substorm and eclipse
28
Spacecraft potential in GEO at substorm
solar array
je
je
jes
secondary
electrons
jes
antenna
j ph
photo-electrons
j ph
antenna
j ph
j ph
Sun
light
j ph
shadow
caused by
antenna
ambient
high-energy
electrons
j ph
j ph
j ph
j ph
je
jes
jes
je
29
Spacecraft potential in GEO at substorm
Potential
Onset of substorm
 d   sc
 1 ~ 2V
Insulator
potential
d
Differential
voltage
spacecraft potential
 sc
time
• Large potential difference builds up between insulator and
satellite potential (i.e. interconnector)
• Arcs occur for DV=|d-sc|>O(100V)
30
What do we do in satellite design?
•
Before launch, we have to check
– Does the satellite charge to the arc threshold?
• Computer simulation
1. Detailed 3D simulation
2. Quick check
– If yes
• Ground test
– Make sure that the satellite operates even with arcs
31
How do we calculate spacecraft charging?
• We solve differential equations;
dsc
1

I i (sc )  I e (sc )  I se (sc )  I si (sc )  I ph (sc )  I be (sc )
dt
Csat


d d  sc  1

ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
dt
Cd
M


The insulator potential d is calculated for each insulator on spacecraft
Csat: Capacitance of spacecraft body w/r/t plasma (F)
Cd: Capacitance per unit area of insulator w/r/t spacecraft body (F/m2)
32
3D spacecraft charging simulation
dsc
1

I i (sc )  I e (sc )  I se (sc )  I si (sc )  I ph (sc )  I be (sc )
dt
Csat


d d  sc  1

ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
dt
Cd
M


• Calculate the currents by following trajectories of
charged particles to each point on spacecraft
– 3D geometry of spacecraft
– Massive computer memory
– Long computation time (~day)
33
3D spacecraft charging simulation
• NASCAP (NASA Charging Analyzer Program) 1970s
• NASCAP-2K 2000s
• MUSCAT (Multi-Utility Spacecraft Charging Analysis Tool)
– Under Development at KIT with JAXA since December 2004
– Spacecraft charging of LEO, PEO, GEO satellites
– Final release in spring 2007
34
3D spacecraft charging simulation
• MUSCAT (Multi-Utility Spacecraft Charging Analysis Tool)
JAVA3D-based GUI + Fortran-based particle simulation code
35
3D spacecraft charging simulation
• MUSCAT (Multi-Utility Spacecraft Charging Analysis Tool)
Gives differential voltage
DV  d  sc
36
3D spacecraft charging simulation
Accuracy depends on
1. Material property data
• Secondary electron, photo-electron, conductivity, etc
2. Environment data
• Plasma density, temperature
3. Satellite geometry
dsc
1

I i (sc )  I e (sc )  I se (sc )  I si (sc )  I ph (sc )  I be (sc )
dt
Csat


d d  sc  1

ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
dt
Cd
M


37
Quick spacecraft charging simulation
•
•
•
Analytical formula of each current
Calculate only a limited number of points
Numerically integrate the differential equations
– Runge-Kutta, etc.
dsc
1

I i (sc )  I e (sc )  I se (sc )  I si (sc )  I ph (sc )  I be (sc )
dt
Csat


d d  sc  1

ji (d )  je (d )  jse (d )  jsi (d )  j ph (d )  jbe (d )  jc (d )
dt
Cd
M


38
QUSCAT (QUick Spacecraft
Charging Analysis Tool)
Body dimension R
Solar panel area = Apanel
insulator patch (Dielectric material)
• Consider a GEO satellite
• Calculate three potential
– body potential, sc
– coverglass potential cg
– insulator path potential d
39
QUSCAT
Abody 

dsc
1 ji (sc )  je ( sc )  jse (sc ) Abody  Apanel  j ph ( sc )

2


dt
Csat 
  ji (cg )  je (cg )  jse (cg )  j ph (cg ) Apanel

dcg
1
d

ji (cg )  je (cg )  jse (cg )  j ph (cg )  jc (cg )  sc
dt
Ccg
dt






dd
1
dsc

ji (d )  je (d )  jse (d )  j ph (d )  jc (d ) 
dt
Cd
dt


• Integrate three differential equations with the initial
conditions sc(t=0)=cg(t=0)=d(t=0)=0
– Runge-Kutta method
• Each j() is given by an analytical formula
– depends on plasma parameters, material selection, sunlight,
thickness,
40
QUSCAT
push this to restart the simulation
push this to stop and change the parameters
parameter selections
Made as JAVA applet
41
QUSCATの走らせ方
1.
2.
3.
4.
5.
6.
7.
Webブラウザでhttp://laplace.ele.kyutech.ac.jp/Charging/charging.htmlにアクセスす
る。
リンクをダブルクリックする
起動と同時にデフォルトのパラメータで走り始めるので、suspendボタンを
押して止める
パラメータをプルボタンで変更し、RUNボタンを押す
グラフが右端付近まで行くと自動的に止まる。横軸の時間は10s位に
なっている。(普通のパソコンで10分はかからない)
再度走らせるには、SUSPENDボタンを押してから、RUNボタンを押せば
よい。
WebブラウザはNetscapeがお勧め
42
宿題
• 問1 自分の名前を画面上に10回表示するアプレッ
トを作って、計算結果のスクリーンショットを提
出する。
• 問2 QUSCATを走らせる。どんな組み合わせでも
良いのでパラメータをdefaultから変更して、計算終
了まで走らせる。
– 計算終了後のスクリーンショットを提出(p.42参照)
– パソコンのOS(Linux,Windows,Mac etc)とバージョン、使
用したブラウザの種類(Netscape, Internet Explorer等々)
とそのバージョン、パソコン、CPUの種類(Pentium、
Celeron等々) を書く。
43
問1
44