expected boolean or range expression, found simple statement (missing parentheses around composite literal?):

621 views
Skip to first unread message

kurasaki

unread,
Jul 19, 2022, 2:58:53 AM7/19/22
to mumax2
Hello all

When I try to run the script below, I get the error message in the title. If anyone knows how to solve the problem, please let me know.

Thank you in advance.

// セル数の設定 2のべき乗がベストです。
Nx := 512
Ny := 512
Nz := 1
setgridsize(Nx, Ny, Nz)   // セル数の適用

// 試料サイズ 単位: メートル
sizeX := 1e-6
sizeY := 1e-6
sizeZ := 1e-9
setcellsize(sizeX/Nx, sizeY/Ny, sizeZ/Nz)  // セルサイズの適用

//試料の形をファイルからロード
setgeom(imageShape("mask.png" ))     //画像から物質の形を策定

// 異方性の設定
defregion(1, xrange(-inf, inf))      //異方性の番号,形(inf:無限大)
Ku1.setregion(1, 1e5)              //異方性の番号, 異方性定数
anisU.setRegion(1, vector(1, 0, 0))  //異方性の番号,異方性の方向

// 初期磁化の設定
m = uniform(1,0,0)                 //初期磁化と異方性の向きは揃える

// 室温
//Temp = 300 //(K)

// 材料定数の設定
Msat  = 1950e3    // 飽和磁化(A/m)
Aex   = 23e-12  // 交換定数(J/m)
alpha = 0.3     // ダンピング定数(-)

// table.txtに磁場の情報を追加
TableAdd(B_ext)

//forループ  初期値; 実行条件; 刻み幅
for i:=0.4; i>0.05; i=i-0.025{  
  print( "B_ext = ",i,"(T)" )  //  現在の磁場を表示
  B_ext = vector(i, 0, 0)        //  磁場を設定
  run(1e-9)                        //  シミュレーション実行
  Snapshot(m)                    //  画像を保存
  TableSave()                    //  table.txtに情報を記録
}

//forループ  初期値; 実行条件; 刻み幅
for i:=0.05; i>-0.4; i=i-0.01{  
  print( "B_ext = ",i,"(T)" )  //  現在の磁場を表示
  B_ext = vector(i, 0, 0)        //  磁場を設定
  run(1e-9)                        //  シミュレーション実行
  Snapshot(m)                    //  画像を保存
  TableSave()                    //  table.txtに情報を記録
}

//forループ  初期値; 実行条件; 刻み幅
for i:=-0.4; i<-0.05; i=i+0.025{  
  print( "B_ext = ",i,"(T)" )  //  現在の磁場を表示
  B_ext = vector(i, 0, 0)        //  磁場を設定
  run(1e-9)                        //  シミュレーション実行
  Snapshot(m)                    //  画像を保存
  TableSave()                    //  table.txtに情報を記録
}

//forループ  初期値; 実行条件; 刻み幅
for i:=-0.05; i<0.4; i=i-+0.01{  
  print( "B_ext = ",i,"(T)" )  //  現在の磁場を表示
  B_ext = vector(i, 0, 0)        //  磁場を設定
  run(1e-9)                        //  シミュレーション実行
  Snapshot(m)                    //  画像を保存
  TableSave()                    //  table.txtに情報を記録
}

Josh Lauzier

unread,
Jul 19, 2022, 4:09:50 AM7/19/22
to mumax2
Hello,

Your for expressions are misformed. The line

for i:=0.4; i>0.05; i=i-0.025 {

should be

for i:=0.4; i>0.05; i=(i-0.025){

It needs the parenthesis to evaluate the "i-0.025" term as one single term. Or better yet, one can do

for i:=0.4; i>0.05; i-=0.025 {

A similar change should be made for the other for expressions.

(As an aside, the full error message often tells you what line it occurs on. In this case, it was "script line 53:14: expected boolean or range expression, found simple statement (missing parentheses around composite literal?):",  which tells you it's line 53 of your file. If you open your file in a text editor, you'll find line 53 is "for i:=0.4; i>0.05; i=i-0.025 {" .  It's not always correct, but often it makes it much easier to diagnose issues.)

Cheers,
Josh L.

kurasaki

unread,
Jul 19, 2022, 4:29:02 AM7/19/22
to mumax2
Hello Dr,Josh

I implemented your advice and got it right.

Best Regards
kurasaki

2022年7月19日火曜日 17:09:50 UTC+9 Josh Lauzier:
Reply all
Reply to author
Forward
0 new messages