|
本帖最后由 再见大麋鹿 于 2016-12-20 01:51 编辑
鄙人 Fortran 小白, 此问题查阅大量资料后无果, 且时间紧张, 故前来请教.
我的程序的思路是:
做两个自变量: time, voltage 的循环
就是先对 time 做一个循环,然后在每一个 time 数值做一个 voltage 的循环
最后得出2个自变量的函数 current=current(voltage, time)
而且我在给定 voltage 的时候是成功的, 也就是说, 原本只有一个 time 的循环, 现在我要在 time 的循环下加上一个 voltage 的循环.
原代码循环部分如下:
[Fortran] 纯文本查看 复制代码 003 | if ( time .ge. time_end ) exit |
005 | if ( time <= time_center ) then |
006 | e_rabi_ 0 = e_rabi_i * exp ( - ( time - time_center ) * * 2 / time_width * * 2 ) |
012 | call exci_rates ( de , sq_fcf , gam , kop , e_rabi_ 0 , e_rabi_ 1 ) |
019 | k_ref ( mc , me , mv , nc , ne , nv ) = kivr ( mc , me , mv , nc , ne , nv ) + kop ( mc , me , mv , nc , ne , nv ) + klu ( mc , me , mv , nc , ne , nv ) |
027 | voltage = voltage_give |
030 | call mol_lead_rates ( voltage , de , v_l , v_r , sq_fcf , klw , klw_l ) |
037 | k_tot ( mc , me , mv , nc , ne , nv ) = k_ref ( mc , me , mv , nc , ne , nv ) + klw ( mc , me , mv , nc , ne , nv ) |
045 | if ( time == 0.0d0 ) then |
055 | stop_time = time_final |
059 | pop_old ( mc , me , mv ) = pop ( mc , me , mv ) |
063 | call multi_to_single ( pop_old , fin ) |
064 | call rk 4 ( fin , time , time_step , fout , k_tot ) |
065 | call single_to_multi ( fout , pop ) |
067 | time = time + time_step |
068 | if ( time < stop_time ) goto 100 |
074 | error_pop = error_pop + ( pop ( mc , me , mv ) - pop_old ( mc , me , mv ) ) * * 2 |
078 | error_pop = SQRT ( error_pop ) / length_coeff |
079 | if ( error_pop > max_error ) then |
080 | stop_time = stop_time + 0.5d0 * time_final |
082 | if ( error_pop > max_error ) goto 100 |
084 | time = time + time_step |
089 | pop_old ( mc , me , mv ) = pop ( mc , me , mv ) |
094 | call multi_to_single ( pop_old , fin ) |
095 | call rk 4 ( fin , time , time_step , fout , k_tot ) |
096 | call single_to_multi ( fout , pop ) |
097 | time = time + time_step |
114 | total_pop = total_pop + pop ( mc , me , mv ) |
115 | pop_el ( mc , me ) = pop_el ( mc , me ) + pop ( mc , me , mv ) |
124 | mean_vib = mean_vib + mv * pop ( mc , me , mv ) |
133 | i_photon = i_photon + klu ( mc , 1 , mv , mc , 0 , nv ) * pop ( mc , 1 , mv ) |
143 | current = current + klw_l ( 0 , me , mv , 1 , ne , nv ) * pop ( 0 , me , mv ) - klw_l ( 1 , ne , nv , 0 , me , mv ) * pop ( 1 , ne , nv ) |
153 | c_in ( mc , me , nc , ne ) = 0.0d0 |
154 | c_out ( mc , me , nc , ne ) = 0.0d0 |
162 | c_in ( 0 , 0 , 1 , 0 ) = c_in ( 0 , 0 , 1 , 0 ) + klw_l ( 0 , 0 , mv , 1 , 0 , nv ) * pop ( 0 , 0 , mv ) |
163 | c_in ( 0 , 0 , 1 , 1 ) = c_in ( 0 , 0 , 1 , 1 ) + klw_l ( 0 , 0 , mv , 1 , 1 , nv ) * pop ( 0 , 0 , mv ) |
164 | c_in ( 0 , 1 , 1 , 0 ) = c_in ( 0 , 1 , 1 , 0 ) + klw_l ( 0 , 1 , mv , 1 , 0 , nv ) * pop ( 0 , 1 , mv ) |
165 | c_in ( 0 , 1 , 1 , 1 ) = c_in ( 0 , 1 , 1 , 1 ) + klw_l ( 0 , 1 , mv , 1 , 1 , nv ) * pop ( 0 , 1 , mv ) |
167 | c_out ( 1 , 0 , 0 , 0 ) = c_out ( 1 , 0 , 0 , 0 ) - klw_l ( 1 , 0 , nv , 0 , 0 , mv ) * pop ( 1 , 0 , nv ) |
168 | c_out ( 1 , 0 , 0 , 1 ) = c_out ( 1 , 0 , 0 , 1 ) - klw_l ( 1 , 0 , nv , 0 , 1 , mv ) * pop ( 1 , 0 , nv ) |
169 | c_out ( 1 , 1 , 0 , 0 ) = c_out ( 1 , 1 , 0 , 0 ) - klw_l ( 1 , 1 , nv , 0 , 0 , mv ) * pop ( 1 , 1 , nv ) |
170 | c_out ( 1 , 1 , 0 , 1 ) = c_out ( 1 , 1 , 0 , 1 ) - klw_l ( 1 , 1 , nv , 0 , 1 , mv ) * pop ( 1 , 1 , nv ) |
175 | write ( * , * ) time , voltage , current * 243.4d0 |
176 | write ( 40 , * ) time , voltage , current * 243.4d0 |
这时候代码是可以正确运行的, 但是我想取若干个:
所以我把这行改成了:
voltage = voltage_min
然后 Output 的前一行加上:
[Fortran] 纯文本查看 复制代码 1 | if ( num_voltage > 0 ) then voltage = voltage + ( voltage_max - voltage_min ) / num_voltageend if |
再然后, 末尾再加一个:
编译没错, 但是, 但是并不是每个 time 数值都做一个voltage的循环, 而是同时作循环:
[Fortran] 纯文本查看 复制代码 01 | 1.000000000000000E-002 40.0000000000000 1.988160357654218E-016 |
02 | 2.000000000000000E-002 80.0000000000000 1.364425784870382E-004 |
03 | 3.000000000000000E-002 120.000000000000 1.370837425057141E-004 |
04 | 4.000000000000000E-002 160.000000000000 2.083606552928942E-004 |
05 | 5.000000000000000E-002 200.000000000000 3.832251385343335E-004 |
06 | 6.000000000000000E-002 240.000000000000 3.846367630381155E-004 |
07 | 7.000000000000001E-002 280.000000000000 4.131201522155061E-004 |
08 | 8.000000000000000E-002 320.000000000000 5.825466767173463E-004 |
09 | 9.000000000000000E-002 360.000000000000 5.852940467602035E-004 |
10 | 0.100000000000000 400.000000000000 5.948948519956353E-004 |
11 | 0.110000000000000 440.000000000000 7.259287371840456E-004 |
12 | 0.120000000000000 480.000000000000 7.304897383455301E-004 |
14 | 38.1800000000010 2000.00000000000 74.8222446587716 |
按理说应该是第一列先都是 1.000000000000000E-002 第二列从 00.0000000000000 每隔 40 数到 2000.000000000000
然后第一列变成 2.000000000000000E-002 第二列重新从 00.0000000000000 每隔 40 数到 2000.000000000000
……
近期是论文dead_line, 心态简直好到爆炸! T.T
最后感谢大家的帮助!
|
|