| | 170 | !Using the equation of electron motion find the phase trajectory. Electron filed E=0 |
| | 171 | !Part 1. Using only dependence of B0 |
| | 172 | integer :: n=1000 |
| | 173 | real(8) :: dt, t, vm, b, rl, om, x, y, vx, vy, B0 |
| | 174 | real(8) :: eq=-4.8e-10, me=9.1e-28, c = 3.0e10 |
| | 175 | !B0=me*c*om/ez |
| | 176 | B0 = 200.0 |
| | 177 | !E0 = 5000 |
| | 178 | !A = 1e-30 |
| | 179 | x=1.0 |
| | 180 | y=1.0 |
| | 181 | vx=1000.0 |
| | 182 | vy=1000.0 |
| | 183 | a=100 |
| | 184 | !b = B0/B0 |
| | 185 | !om = eq*B0/me*c |
| | 186 | !vm = A*om |
| | 187 | !print *, vm |
| | 188 | !rl = c/om |
| | 189 | !vx = vm/vm |
| | 190 | !vy = vm/vm |
| | 191 | !x = x/rl |
| | 192 | !y = y/rl |
| | 193 | !print *, rl |
| | 194 | t = 1.0e-8 |
| | 195 | dt = t/float(n) |
| | 196 | |
| | 197 | open (1,file='1',status='unknown') |
| | 198 | |
| | 199 | do i=1,n |
| | 200 | vx = vx+(B0*eq)/(c*me)*vy*dt |
| | 201 | vy = vy-(B0*eq)/(c*me)*vx*dt |
| | 202 | x = x+vx*dt |
| | 203 | y = y+vy*dt |
| | 204 | write(1,*) x, vx |
| | 205 | end do |
| | 206 | |
| | 207 | pause |
| | 208 | end program |
| | 209 | }}} |
| | 210 | |
| | 211 | |
| | 212 | == 8. Electron motion in electric and magnetic filed. == |
| | 213 | {{{ |
| | 214 | #!fortran |
| | 215 | !Like in program 7.Part 1 |
| | 216 | integer :: n=1000 |
| | 217 | real(8) :: dt, t, vm, om, x, y, vx, vy, B0,b |
| | 218 | real(8) :: eq=4.8e-10, me=9.1e-28, c = 3.0e10, R=1.0 |
| | 219 | x = 1.0 |
| | 220 | y = 1.0 |
| | 221 | a = 0.5 |
| | 222 | |
| | 223 | vx = 1.0e09 |
| | 224 | vy = 1.0e09 |
| | 225 | E0=0.0 |
| | 226 | B0 = 200.0 |
| | 227 | |
| | 228 | b=(2*3.14*6)/(1.0e09) |
| | 229 | |
| | 230 | !B0 = 1e-25 |
| | 231 | !E0 = 5000 |
| | 232 | !A = 1e-30 |
| | 233 | !b = B0/B0 |
| | 234 | !om = eq*B0/me*c |
| | 235 | !vm = A*om |
| | 236 | !print *, vm |
| | 237 | !rl = c/om |
| | 238 | !vx = vm/vm |
| | 239 | !vy = vm/vm |
| | 240 | !x = x/rl |
| | 241 | !y = y/rl |
| | 242 | !print *, rl |
| | 243 | t = 1.00e-08 |
| | 244 | dt = t/float(n) |
| | 245 | |
| | 246 | |
| | 247 | open (1,file='1',status='unknown') |
| | 248 | |
| | 249 | do i=1,n |
| | 250 | |
| | 251 | Bz = B0*(1+a*y) |
| | 252 | !Bz = B0 |
| | 253 | x = x + vx*dt |
| | 254 | y = y + vy*dt |
| | 255 | |
| | 256 | !vx = vx + (vy*eq*Bz)/(c*me)*dt |
| | 257 | !vy = vy - (vx*eq*Bz)/(c*me)*dt |
| | 258 | |
| | 259 | |
| | 260 | if(i*dt.gt.b) then |
| | 261 | E0 = 5.0 |
| | 262 | end if |
| | 263 | |
| | 264 | vx = vx +(eq*E0)/(me)*dt+(vy*eq*Bz)/(c*me)*dt |
| | 265 | vy = vy + (eq*E0)/(me)*dt-(vx*eq*Bz)/(c*me)*dt |
| | 266 | ! x = x + vx*dt |
| | 267 | !y = y + vy*dt |
| | 268 | |
| | 269 | !print *, vx, vy |
| | 270 | |
| | 271 | |
| | 272 | |
| | 273 | |
| | 274 | |
| | 275 | write (1,*) x, y |
| | 276 | |
| | 277 | end do |
| | 278 | pause |
| | 279 | end program |
| | 280 | }}} |
| | 281 | == 9. Electron motion in electric and magnetic filed == |
| | 282 | {{{ |
| | 283 | #!fortran |
| | 284 | !Like in program 8. Part 2. the differnece is that here we are using different functions |
| | 285 | !for vx and vy |
| | 286 | integer :: n=1000 |
| | 287 | real(8) :: dt, t, vm, om, x, y, vx, vy, B0,b |
| | 288 | real(8) :: eq=4.8e-10, me=9.1e-28, c = 3.0e10, R=1.0 |
| | 289 | x = 1.0 |
| | 290 | y = 1.0 |
| | 291 | a = 0.5 |
| | 292 | |
| | 293 | vx = 1.0e09 |
| | 294 | vy = 1.0e09 |
| | 295 | E0 = 0.0 |
| | 296 | B0 = 200.0 |
| | 297 | |
| | 298 | b = (2*3.14)/(1.0e09) |
| | 299 | |
| | 300 | t = 1.00e-08 |
| | 301 | dt = t/float(n) |
| | 302 | |
| | 303 | |
| | 304 | open (1,file='1',status='unknown') |
| | 305 | |
| | 306 | do i=1,n |
| | 307 | |
| | 308 | Bz = B0*(1+a*y) |
| | 309 | !Bz = B0 |
| | 310 | x = x + vx*dt |
| | 311 | y = y + vy*dt |
| | 312 | |
| | 313 | vx = vx + (vy*eq*Bz)/(c*me)*dt |
| | 314 | vy = vy - (vx*eq*Bz)/(c*me)*dt |
| | 315 | |
| | 316 | |
| | 317 | if(i*dt.gt.b) then |
| | 318 | E0 = 3.0 |
| | 319 | end if |
| | 320 | |
| | 321 | vx = vx + (vy*eq*Bz)/(c*me)*dt |
| | 322 | vy = vy + (eq*E0)/(me)*dt - (vx*eq*Bz)/(c*me)*dt |
| | 323 | x = x - vx*dt |
| | 324 | y = y + vy*dt |
| | 325 | |
| | 326 | !print *, vx, vy |
| | 327 | |
| | 328 | |
| | 329 | |
| | 330 | |
| | 331 | |
| | 332 | write (1,*) x, y |
| | 333 | |
| | 334 | end do |
| | 335 | pause |
| | 336 | end program |
| | 337 | }}} |
| | 338 | == 10. Electron motion only in magnetic field == |
| | 339 | {{{ |
| | 340 | #!fortran |
| | 341 | ! Like in program 7. Part 2 here we have dependence of magnetic filed in z coordinate |
| | 342 | integer :: N = 1500 |
| | 343 | real(8) :: x = 2.5, y = 0.5, B0 = 500.0, We = 4.0054e-08, b = 2.0, pi = 3.14159, m = 9.1e-28, e = -4.8e-10, c = 2.99e10 |
| | 344 | real(8) vx, vy, v, dt, t |
| | 345 | |
| | 346 | v = sqrt(2*We/m) |
| | 347 | vx = sin(pi/4.0)*v |
| | 348 | vy = cos(pi/4.0)*v |
| | 349 | t = 5e-9 |
| | 350 | dt=t/float(N) |
| | 351 | !Norma |
| | 352 | !tau = t*10e8 |
| | 353 | !me = m*1e28 |
| | 354 | !qe = e*1e10 |
| | 355 | !vl = c*1e-10 |
| | 356 | !ve = v/c |
| | 357 | !vx = sin(pi/4.0)*v |
| | 358 | !vy = cos(pi/4.0)*v |
| | 359 | !dt = tau/float(N) |
| | 360 | |
| | 361 | open (1,file='mov',status='replace') |
| | 362 | do i=1,N |
| | 363 | Bz = B0*(1-b**2*(x**2+y**2)) |
| | 364 | x = x + vx*dt |
| | 365 | y = y + vy*dt |
| | 366 | vx = vx + vy/m*Bz*e/c*dt |
| | 367 | vy = vy - vx/m*Bz*e/c*dt |
| | 368 | print *, x, y |
| | 369 | pause |
| | 370 | write(1,*) y, x |
| | 371 | end do |
| | 372 | end program |
| | 373 | }}} |
| | 374 | |
| | 375 | |
| | 376 | |
| | 377 | == 11. Determination the proton energy and power == |
| | 378 | {{{ |
| | 379 | #!fortran |
| | 380 | integer :: n=1000 |
| | 381 | real(8) :: dt, t, x, y, vx, vy, v, E, W |
| | 382 | real(8) :: mp = 1.67e-24, q = 4.8e-10 |
| | 383 | x = 1.0 |
| | 384 | y = 1.0 |
| | 385 | d = 1.0 |
| | 386 | a = 30 |
| | 387 | W0 = 1000 |
| | 388 | |
| | 389 | v = sqrt(2*W0/mp) |
| | 390 | |
| | 391 | |
| | 392 | t = 1.00e-05 |
| | 393 | dt = t/float(n) |
| | 394 | |
| | 395 | |
| | 396 | open (1,file='1',status='unknown') |
| | 397 | |
| | 398 | do i=1,n |
| | 399 | |
| | 400 | vx = v*sin(a) |
| | 401 | vy = v*cos(a) |
| | 402 | x = x + vx*dt |
| | 403 | y = y + vy*dt |
| | 404 | |
| | 405 | E = (4*3.14*mp*y)/d |
| | 406 | W = (E*q)/ x |
| | 407 | |
| | 408 | |
| | 409 | |
| | 410 | |
| | 411 | !print *, vx, vy |
| | 412 | |
| | 413 | |
| | 414 | |
| | 415 | |
| | 416 | write (1,*) W, t |
| | 417 | |
| | 418 | end do |
| | 419 | pause |
| | 420 | end program |
| | 421 | }}} |
| | 422 | == 12. Runge-Kutta method for harmonic oscillations == |
| | 423 | {{{ |
| | 424 | #!fortran |
| | 425 | ! metod Runge-Kuta. Oscillator. Part 1 |
| | 426 | |
| | 427 | |
| 222 | | return |
| 223 | | end |
| 224 | | |
| 225 | | |
| 226 | | subroutine out (t, u, du, ih, nd, pr) |
| 227 | | real u(2), du(2), pr(5) |
| 228 | | common /a/ dt, k, n, A, Vm, om |
| 229 | | |
| 230 | | if(t.ge.k*(dt/50.)) then |
| 231 | | write (2,1) t/om, u(1)*Vm, u(2)*A |
| 232 | | k=k+1 |
| 233 | | else |
| 234 | | end if |
| 235 | | |
| 236 | | 1 format (f8.3, f8.3, f8.3) |
| 237 | | return |
| 238 | | end |
| 239 | | |
| 240 | | |
| 241 | | |
| 242 | | }}} |
| 243 | | |
| 244 | | == Console9.f90 == |
| 245 | | {{{ |
| 246 | | #!fortran |
| 247 | | ! Console9.f90 |
| 248 | | ! |
| 249 | | ! FUNCTIONS: |
| 250 | | ! Console9 - Entry point of console application. |
| 251 | | ! |
| 252 | | |
| 253 | | !**************************************************************************** |
| 254 | | ! |
| 255 | | ! PROGRAM: Console9 |
| 256 | | ! |
| 257 | | ! PURPOSE: Entry point for the console application. |
| 258 | | ! |
| 259 | | !**************************************************************************** |
| 260 | | |
| 261 | | program Console9 |
| 262 | | |
| 263 | | implicit none |
| 264 | | |
| 265 | | ! Variables |
| 266 | | |
| 267 | | ! Body of Console9 |
| 268 | | print *, 'Hello World' |
| 269 | | |
| 270 | | end program Console9 |
| 271 | | |
| 272 | | }}} |
| 273 | | |
| 274 | | |
| 275 | | == Console10.f90 == |
| 276 | | {{{ |
| 277 | | #!fortran |
| 278 | | ! Osc_rk_0.f90 |
| 279 | | ! |
| 280 | | ! Lab #3 |
| 281 | | ! metod Runge-Kuta. Oscillator. |
| 282 | | |
| 283 | | external fct, out |
| 284 | | real aux(8,4) |
| 285 | | common /a/ dt, k, n, vm, A, om, rl, x, y, r, u(1), u(2), u(3), u(4) |
| 286 | | |
| 287 | | real :: pr(5)=(/0., 2*3.14159*20., 2*3.14159/50, .0001, .0/) |
| 288 | | |
| 289 | | |
| 290 | | integer :: nd = 2 |
| 291 | | real :: dt = 2*3.14159265 |
| 292 | | real :: t |
| 293 | | real :: c = 3.0e10 |
| 294 | | !B0=me*c*om/ez |
| 295 | | B0 = 200.0 |
| 296 | | E0 = 5000 |
| 297 | | eq = 4.8e-10 |
| 298 | | me = 9.1e-28 |
| 299 | | om = eq*B0/me*c |
| 300 | | A = 2.0 |
| 301 | | vm = A*om |
| 302 | | n = 1 |
| 303 | | k = 1 |
| 304 | | b = B0/B0 |
| 305 | | rl = c/om |
| 306 | | u(1) = vm/vm |
| 307 | | u(2) = vm/vm |
| 308 | | u(3) = x/rl |
| 309 | | u(4) = y/rl |
| 310 | | |
| 311 | | |
| 312 | | |
| 313 | | |
| 314 | | open (unit=2, file = '1_rk.dat', status='unknown') |
| 315 | | |
| 316 | | write(*,*) 'x=', u(3), 'vx=', u(1), 'y=', u(4), 'vy=', u(2) |
| 317 | | call rkgs(pr, u, du, nd, ih, fct, out, aux) |
| 318 | | |
| 319 | | write(2,*) 'ih=', ih |
| 320 | | |
| 321 | | |
| 322 | | end |
| 323 | | |
| 324 | | subroutine fct (t, u, du) |
| 325 | | |
| 326 | | real u(3), du(3), u(4), du(4) |
| 327 | | common /a/ dt, k, n, vm, A, om, rl, x, y, r, u(1), u(2), u(3), u(4) |
| 328 | | |
| 329 | | du(1) = -u(3) |
| 330 | | du(2) = u(4) |
| 331 | | du(3) = u(1) |
| 332 | | du(4) = u(2) |
| 511 | | ! Console11.f90 |
| 512 | | ! |
| 513 | | ! FUNCTIONS: |
| 514 | | ! Console11 - Entry point of console application. |
| 515 | | ! |
| 516 | | |
| 517 | | !**************************************************************************** |
| 518 | | ! |
| 519 | | ! PROGRAM: Console11 |
| 520 | | ! |
| 521 | | ! PURPOSE: Entry point for the console application. |
| 522 | | ! |
| 523 | | !**************************************************************************** |
| 524 | | |
| 525 | | program Console11 |
| 526 | | |
| 527 | | implicit none |
| 528 | | |
| 529 | | ! Variables |
| 530 | | |
| 531 | | ! Body of Console11 |
| 532 | | print *, 'Hello World' |
| 533 | | |
| 534 | | end program Console11 |
| 535 | | |
| 536 | | }}} |
| 537 | | |
| 538 | | == Console12.f90 == |
| 539 | | {{{ |
| 540 | | #!fortran |
| 541 | | ! Console12.f90 |
| 542 | | ! |
| 543 | | ! FUNCTIONS: |
| 544 | | ! Console12 - Entry point of console application. |
| 545 | | ! |
| 546 | | |
| 547 | | !**************************************************************************** |
| 548 | | ! |
| 549 | | ! PROGRAM: Console12 |
| 550 | | ! |
| 551 | | ! PURPOSE: Entry point for the console application. |
| 552 | | ! |
| 553 | | !**************************************************************************** |
| 554 | | |
| 555 | | program Console12 |
| 556 | | |
| 557 | | implicit none |
| 558 | | |
| 559 | | ! Variables |
| 560 | | |
| 561 | | ! Body of Console12 |
| 562 | | print *, 'Hello World' |
| 563 | | |
| 564 | | end program Console12 |
| 565 | | |
| 566 | | }}} |
| 567 | | |
| 568 | | == Console13.f90 == |
| 569 | | {{{ |
| 570 | | #!fortran |
| 571 | | integer :: n=1000 |
| 572 | | real(8) :: dt, t, vm, b, rl, om, x, y, vx, vy, B0 |
| 573 | | real(8) :: eq=-4.8e-10, me=9.1e-28, c = 3.0e10 |
| 574 | | !B0=me*c*om/ez |
| 575 | | B0 = 200.0 |
| 576 | | !E0 = 5000 |
| 577 | | !A = 1e-30 |
| 578 | | x=1.0 |
| 579 | | y=1.0 |
| 580 | | vx=1000.0 |
| 581 | | vy=1000.0 |
| 582 | | a=100 |
| 583 | | !b = B0/B0 |
| 584 | | !om = eq*B0/me*c |
| 585 | | !vm = A*om |
| 586 | | !print *, vm |
| 587 | | !rl = c/om |
| 588 | | !vx = vm/vm |
| 589 | | !vy = vm/vm |
| 590 | | !x = x/rl |
| 591 | | !y = y/rl |
| 592 | | !print *, rl |
| 593 | | t = 1.0e-8 |
| 594 | | dt = t/float(n) |
| 595 | | |
| 596 | | open (1,file='1',status='unknown') |
| 597 | | |
| 598 | | do i=1,n |
| 599 | | vx = vx+(B0*eq)/(c*me)*vy*dt |
| 600 | | vy = vy-(B0*eq)/(c*me)*vx*dt |
| 601 | | x = x+vx*dt |
| 602 | | y = y+vy*dt |
| 603 | | write(1,*) x, vx |
| 604 | | end do |
| 605 | | |
| 606 | | pause |
| 607 | | end program |
| 608 | | }}} |
| 609 | | |
| 610 | | == Console15.f90 == |
| 611 | | {{{ |
| 612 | | #!fortran |
| 613 | | x = (/1,5/) |
| 614 | | print *, x |
| 615 | | end |
| 616 | | }}} |
| 617 | | |
| 618 | | == Console16.f90 == |
| 619 | | {{{ |
| 620 | | #!fortran |
| 621 | | integer :: n=1000 |
| 622 | | real(8) :: dt, t, vm, om, x, y, vx, vy, B0,b |
| 623 | | real(8) :: eq=4.8e-10, me=9.1e-28, c = 3.0e10, R=1.0 |
| 624 | | x = 1.0 |
| 625 | | y = 1.0 |
| 626 | | a = 0.5 |
| 627 | | |
| 628 | | vx = 1.0e09 |
| 629 | | vy = 1.0e09 |
| 630 | | E0=0.0 |
| 631 | | B0 = 200.0 |
| 632 | | |
| 633 | | b=(2*3.14*6)/(1.0e09) |
| 634 | | |
| 635 | | !B0 = 1e-25 |
| 636 | | !E0 = 5000 |
| 637 | | !A = 1e-30 |
| 638 | | !b = B0/B0 |
| 639 | | !om = eq*B0/me*c |
| 640 | | !vm = A*om |
| 641 | | !print *, vm |
| 642 | | !rl = c/om |
| 643 | | !vx = vm/vm |
| 644 | | !vy = vm/vm |
| 645 | | !x = x/rl |
| 646 | | !y = y/rl |
| 647 | | !print *, rl |
| 648 | | t = 1.00e-08 |
| 649 | | dt = t/float(n) |
| 650 | | |
| 651 | | |
| 652 | | open (1,file='1',status='unknown') |
| 653 | | |
| 654 | | do i=1,n |
| 655 | | |
| 656 | | Bz = B0*(1+a*y) |
| 657 | | !Bz = B0 |
| 658 | | x = x + vx*dt |
| 659 | | y = y + vy*dt |
| 660 | | |
| 661 | | !vx = vx + (vy*eq*Bz)/(c*me)*dt |
| 662 | | !vy = vy - (vx*eq*Bz)/(c*me)*dt |
| 663 | | |
| 664 | | |
| 665 | | if(i*dt.gt.b) then |
| 666 | | E0 = 5.0 |
| 667 | | end if |
| 668 | | |
| 669 | | vx = vx +(eq*E0)/(me)*dt+(vy*eq*Bz)/(c*me)*dt |
| 670 | | vy = vy + (eq*E0)/(me)*dt-(vx*eq*Bz)/(c*me)*dt |
| 671 | | ! x = x + vx*dt |
| 672 | | !y = y + vy*dt |
| 673 | | |
| 674 | | !print *, vx, vy |
| 675 | | |
| 676 | | |
| 677 | | |
| 678 | | |
| 679 | | |
| 680 | | write (1,*) x, y |
| 681 | | |
| 682 | | end do |
| 683 | | pause |
| 684 | | end program |
| 685 | | }}} |
| 686 | | |
| 687 | | == Console17.f90 == |
| 688 | | {{{ |
| 689 | | #!fortran |
| 690 | | integer :: N = 1500 |
| 691 | | real(8) :: x = 2.5, y = 0.5, B0 = 500.0, We = 4.0054e-08, b = 2.0, pi = 3.14159, m = 9.1e-28, e = -4.8e-10, c = 2.99e10 |
| 692 | | real(8) vx, vy, v, dt, t |
| 693 | | |
| 694 | | v = sqrt(2*We/m) |
| 695 | | vx = sin(pi/4.0)*v |
| 696 | | vy = cos(pi/4.0)*v |
| 697 | | t = 5e-9 |
| 698 | | dt=t/float(N) |
| 699 | | !Norma |
| 700 | | !tau = t*10e8 |
| 701 | | !me = m*1e28 |
| 702 | | !qe = e*1e10 |
| 703 | | !vl = c*1e-10 |
| 704 | | !ve = v/c |
| 705 | | !vx = sin(pi/4.0)*v |
| 706 | | !vy = cos(pi/4.0)*v |
| 707 | | !dt = tau/float(N) |
| 708 | | |
| 709 | | open (1,file='mov',status='replace') |
| 710 | | do i=1,N |
| 711 | | Bz = B0*(1-b**2*(x**2+y**2)) |
| 712 | | x = x + vx*dt |
| 713 | | y = y + vy*dt |
| 714 | | vx = vx + vy/m*Bz*e/c*dt |
| 715 | | vy = vy - vx/m*Bz*e/c*dt |
| 716 | | print *, x, y |
| 717 | | pause |
| 718 | | write(1,*) y, x |
| 719 | | end do |
| 720 | | end program |
| 721 | | }}} |
| 722 | | |
| 723 | | == Console18.f90 == |
| 724 | | {{{ |
| 725 | | #!fortran |
| 726 | | ! Osc_rk_0.f90 |
| 727 | | ! |
| 728 | | ! Lab #3 |
| 729 | | ! metod Runge-Kuta. Oscillator. |
| | 638 | |
| | 639 | ! metod Runge-Kuta. Oscillator. Part 2 (the differnece between part 1 is that here we are |
| | 640 | ! using onother function for du(1)) |
| 1164 | | ! Console20.f90 |
| 1165 | | ! |
| 1166 | | ! FUNCTIONS: |
| 1167 | | ! Console20 - Entry point of console application. |
| 1168 | | ! |
| 1169 | | |
| 1170 | | !**************************************************************************** |
| 1171 | | ! |
| 1172 | | ! PROGRAM: Console20 |
| 1173 | | ! |
| 1174 | | ! PURPOSE: Entry point for the console application. |
| 1175 | | ! |
| 1176 | | !**************************************************************************** |
| 1177 | | |
| 1178 | | program Console20 |
| 1179 | | |
| 1180 | | implicit none |
| 1181 | | |
| 1182 | | ! Variables |
| 1183 | | |
| 1184 | | ! Body of Console20 |
| 1185 | | print *, 'Hello World' |
| 1186 | | |
| 1187 | | end program Console20 |
| 1188 | | |
| 1189 | | }}} |
| 1190 | | |
| 1191 | | == Console21.f90 == |
| 1192 | | {{{ |
| 1193 | | #!fortran |
| 1194 | | integer :: n=1000 |
| 1195 | | real(8) :: dt, t, vm, om, x, y, vx, vy, B0,b |
| 1196 | | real(8) :: eq=4.8e-10, me=9.1e-28, c = 3.0e10, R=1.0 |
| 1197 | | x = 1.0 |
| 1198 | | y = 1.0 |
| 1199 | | a = 0.5 |
| 1200 | | |
| 1201 | | vx = 1.0e09 |
| 1202 | | vy = 1.0e09 |
| 1203 | | E0 = 0.0 |
| 1204 | | B0 = 200.0 |
| 1205 | | |
| 1206 | | b = (2*3.14)/(1.0e09) |
| 1207 | | |
| 1208 | | t = 1.00e-08 |
| 1209 | | dt = t/float(n) |
| 1210 | | |
| 1211 | | |
| 1212 | | open (1,file='1',status='unknown') |
| 1213 | | |
| 1214 | | do i=1,n |
| 1215 | | |
| 1216 | | Bz = B0*(1+a*y) |
| 1217 | | !Bz = B0 |
| 1218 | | x = x + vx*dt |
| 1219 | | y = y + vy*dt |
| 1220 | | |
| 1221 | | vx = vx + (vy*eq*Bz)/(c*me)*dt |
| 1222 | | vy = vy - (vx*eq*Bz)/(c*me)*dt |
| 1223 | | |
| 1224 | | |
| 1225 | | if(i*dt.gt.b) then |
| 1226 | | E0 = 3.0 |
| 1227 | | end if |
| 1228 | | |
| 1229 | | vx = vx + (vy*eq*Bz)/(c*me)*dt |
| 1230 | | vy = vy + (eq*E0)/(me)*dt - (vx*eq*Bz)/(c*me)*dt |
| 1231 | | x = x - vx*dt |
| 1232 | | y = y + vy*dt |
| 1233 | | |
| 1234 | | !print *, vx, vy |
| 1235 | | |
| 1236 | | |
| 1237 | | |
| 1238 | | |
| 1239 | | |
| 1240 | | write (1,*) x, y |
| 1241 | | |
| 1242 | | end do |
| 1243 | | pause |
| 1244 | | end program |
| 1245 | | }}} |
| 1246 | | |
| 1247 | | == Console22.f90 == |
| 1248 | | {{{ |
| 1249 | | #!fortran |
| 1250 | | integer :: n=1000 |
| 1251 | | real(8) :: dt, t, x, y, vx, vy, v, E, W |
| 1252 | | real(8) :: mp = 1.67e-24, q = 4.8e-10 |
| 1253 | | x = 1.0 |
| 1254 | | y = 1.0 |
| 1255 | | d = 1.0 |
| 1256 | | a = 30 |
| 1257 | | W0 = 1000 |
| 1258 | | |
| 1259 | | v = sqrt(2*W0/mp) |
| 1260 | | |
| 1261 | | |
| 1262 | | t = 1.00e-05 |
| 1263 | | dt = t/float(n) |
| 1264 | | |
| 1265 | | |
| 1266 | | open (1,file='1',status='unknown') |
| 1267 | | |
| 1268 | | do i=1,n |
| 1269 | | |
| 1270 | | vx = v*sin(a) |
| 1271 | | vy = v*cos(a) |
| 1272 | | x = x + vx*dt |
| 1273 | | y = y + vy*dt |
| 1274 | | |
| 1275 | | E = (4*3.14*mp*y)/d |
| 1276 | | W = (E*q)/ x |
| 1277 | | |
| 1278 | | |
| 1279 | | |
| 1280 | | |
| 1281 | | !print *, vx, vy |
| 1282 | | |
| 1283 | | |
| 1284 | | |
| 1285 | | |
| 1286 | | write (1,*) W, t |
| 1287 | | |
| 1288 | | end do |
| 1289 | | pause |
| 1290 | | end program |
| 1291 | | }}} |
| 1292 | | |
| 1293 | | == Console24.f90 == |
| 1294 | | {{{ |
| 1295 | | #!fortran |
| 1296 | | |
| 1297 | | ! Lab #1 |
| 1298 | | ! metod Runge-Kuta. Rezonans i avtorezonans. |
| | 1058 | ! Using metod Runge-Kuta. . |
| 1776 | | ! ! program El in a mirro trap, parabolic approximation of the magnetic field |
| 1777 | | ! for a mirror trap. ECR |
| 1778 | | |
| 1779 | | real :: ez = 4.8e-10, c=3.0e10, me=9.1e-28, f=2.4e09, pi=3.14159265 |
| 1780 | | |
| 1781 | | common/a/ gx(250),gy(250),x,y,z,ux,uy,uz,rl,gm,tp,pi,dt,cl2,al,dl,d |
| 1782 | | |
| 1783 | | |
| 1784 | | open (unit=1, file = 'input_t.dat') |
| 1785 | | open (unit=2, file = 'res.dat') |
| 1786 | | ! |
| 1787 | | ! |
| 1788 | | call cpu_time(start) |
| 1789 | | ! |
| 1790 | | read(1,*) kt,kd,E,al,R,B00,x,y,z,W0,fi |
| 1791 | | write(2,1) kt,kd,E,al,R,B00,x,y,z,W0,fi |
| 1792 | | 1 format('kt='I7,2x,'kd=',I3,2x,'E(kV/cm)=',f4.1,2x,'al=',e10.3,2x, & |
| 1793 | | 'R=',f5.3,2x,'B00(%)=',f8.5/'x(cm) =',f4.1,2x,'y(cm) =',f4.1,2x, & |
| 1794 | | 'z(cm)=',f4.1,2x,'W0(eV)=',e10.3,2x,'fi=',f5.1) |
| 1795 | | 2 format('g0=',e10.3,2x,'B0=',f6.1,2x,'cl=',e10.3,2x,'rl =',f6.2/ & |
| 1796 | | 'wmax=',e10.3,2x,'v0=',e10.3,2x,'w00=',e10.3,2x,'rc=',e10.3) |
| 1797 | | |
| 1798 | | pi2=2.0*pi |
| 1799 | | |
| 1800 | | DL=8.0 |
| 1801 | | D=12.0 |
| 1802 | | fi=fi/180.*pi |
| 1803 | | |
| 1804 | | v0=sqrt(1.-1./(1.+w0/511000.)**2) ! ��������� �������� ��������� � �������� � |
| 1805 | | |
| 1806 | | write(*,*) v0*3.0e8 ! ��������� �������� ��������� � m/c |
| 1807 | | U0=v0/sqrt(1.0-v0**2) ! ��������� ������� ��������� � �������� mc |
| 1808 | | W00=511000.*(sqrt(1.0+u0**2)-1.0) ! ���� ��� ��������� ������� |
| 1809 | | om=2.0*pi*f |
| 1810 | | rl=c/om ! �������������� ������ ������������� �������� |
| 1811 | | zm=dl/2.0 ! ������� ���������� |
| 1812 | | |
| 1813 | | ! ������ ��������� cl, ������������� �������� ���������� ���� |
| 1814 | | ! �������, ����� �������� �������� ���������� ��������� |
| 1815 | | cl=(zm/rl)/sqrt(R-1.0) |
| 1816 | | cl2=cl*cl |
| 1817 | | zm=zm/rl ! ���������� |
| 1818 | | |
| 1819 | | E=E*1.0e05/3.0e04 ! ��������� ��� ���� � ���� |
| 1820 | | g0=ez*E/(me*c*om) ! ������������ ��������� ��� ���� |
| 1821 | | |
| 1822 | | B0=me*c*om/ez ! ����������� �������� �������� ���������� ���� - ECR ��� ��������� � ������ ����� |
| 1823 | | wmax=511.0*2.0*g0**(2.0/3.0) ! ������������ �������� ������� ��� ��� � ���������� ������������� � ��������� ���� |
| 1824 | | rc=v0*3.0e10/om ! |
| | 1529 | |
| | 1530 | ! Using the same condition like in program 16 |
| | 1531 | ! metod Runge-Kuta. |
| | 1532 | external fct, out |
| | 1533 | real aux(8,4) |
| | 1534 | common /a/ dt, k, n, g0, om, B0, B, a, y, rl |
| | 1535 | |
| | 1536 | real :: pr(5)=(/0., 2*3.14159*200., 2*3.14159/50, .0001, .0/) |
| | 1537 | real :: u(4) = (/0., 0., 0., 0./) |
| | 1538 | real :: du(4) = (/0.25, 0.25, 0.25, 0.25/) |
| | 1539 | |
| | 1540 | integer :: nd = 4 |
| | 1541 | real :: dt = 2*3.14159265 |
| | 1542 | |
| | 1543 | real :: t, m0, B, B0, a |
| | 1544 | real :: f0 = 0.00 |
| | 1545 | f = 2.45e09 |
| | 1546 | pi = 3.14159265 |
| | 1547 | ez = 4.8e-10 |
| | 1548 | m0 = 9.1e-28 |
| | 1549 | c = 3.0e10 |
| | 1550 | om = 2*pi*f |
| | 1551 | E0 = 5. |
| | 1552 | E = E0 |
| | 1553 | a = 0.00034 |
| | 1554 | B0 = m0*c*om/ez |
| | 1555 | g0 = E0/B0 |
| | 1556 | B = B0 |
| | 1557 | b = B/B0 |
| | 1558 | rl = c/om |
| | 1559 | u(1) = 0. |
| | 1560 | u(2) = 0. |
| | 1561 | u(3) = 0. |
| | 1562 | u(4) = 0. |
| | 1563 | write (*,*) g0, B0, b, E, rl |
| | 1564 | pause |
| | 1565 | |
| | 1566 | |
| 1857 | | tp=-(1.+b00)*dt/2. |
| 1858 | | call motion(l) |
| 1859 | | if (k.eq.km+kd) then ! ����� ����������� ����� kd ��������� ����� |
| 1860 | | w=(gm-1.0)*511.0 |
| 1861 | | write(2,3) tm/(2.*pi), x*rl,y*rl,z*rl, w |
| 1862 | | |
| 1863 | | km=km+kd |
| 1864 | | else |
| 1865 | | end if |
| 1866 | | if (k.eq.kp+m) then ! ������� ��������� ����� ��� ��� ���� |
| 1867 | | kp=kp+m |
| 1868 | | else |
| 1869 | | end if |
| 1870 | | end do |
| 1871 | | 3 format(7f12.5) |
| 1872 | | |
| 1873 | | |
| 1874 | | call cpu_time(finish) |
| 1875 | | write(2,*) 'cpu-time =', finish-start |
| 1876 | | end |
| 1877 | | |
| 1878 | | subroutine motion(l) |
| 1879 | | common/a/ gx(250),gy(250),x,y,z,ux,uy,uz,rl,gm,tp,pi,dt,cl2,al,dl,d |
| 1880 | | |
| 1881 | | ! �������� ��������� ���� ������� ���������� ���� (���� 2) |
| 1882 | | |
| 1883 | | r = sqrt(x*x + y*y) |
| 1884 | | bxp=-x*z/cl2 |
| 1885 | | byp=-y*z/cl2 |
| 1886 | | bzp=1.0+z*z/cl2-r*r/(2.*cl2) |
| 1887 | | |
| 1888 | | ! bxp=0.0 |
| 1889 | | ! byp=0.0 |
| 1890 | | ! bzp=1.0 |
| 1891 | | ! ����� ������ |
| 1892 | | u=sqrt(ux**2+uy**2) |
| 1893 | | |
| 1894 | | ! �������� ��� ������������� ���� (���� 3) |
| 1895 | | uxm = ux + gx(l) |
| 1896 | | uym = uy + gy(l) |
| 1897 | | uzm = uz |
| 1898 | | |
| 1899 | | gmn = sqrt(1 + uxm*uxm + uym*uym + uzm*uzm) |
| 1900 | | |
| 1901 | | tg = tp/gmn |
| 1902 | | tx = tg * bxp |
| 1903 | | ty = tg * byp |
| 1904 | | tz = tg * bzp |
| 1905 | | |
| 1906 | | uxr = uxm + uym*tz - uzm*ty |
| 1907 | | uyr = uym + uzm*tx - uxm*tz |
| 1908 | | uzr = uzm + uxm*ty - uym*tx |
| 1909 | | gmn = sqrt(1 + uxm*uxm + uym*uym + uzm*uzm) |
| 1910 | | |
| 1911 | | txyzr= 1.+ tx*tx + ty*ty + tz*tz |
| 1912 | | |
| 1913 | | sx = 2*tx/txyzr |
| 1914 | | sy = 2*ty/txyzr |
| 1915 | | sz = 2*tz/txyzr |
| 1916 | | |
| 1917 | | uxp = uxm + uyr*sz - uzr*sy |
| 1918 | | uyp = uym + uzr*sx - uxr*sz |
| 1919 | | uzp = uzm + uxr*sy - uyr*sx |
| 1920 | | |
| 1921 | | ux = uxp + gx(l) |
| 1922 | | uy = uyp + gy(l) |
| 1923 | | uz = uzp |
| 1924 | | |
| 1925 | | gm = sqrt (1. + ux**2 + uy**2 + uz**2) |
| 1926 | | gt=dt/gm |
| 1927 | | x = x + ux*gt |
| 1928 | | y = y + uy*gt |
| 1929 | | z = z + uz*gt |
| 1930 | | |
| 1931 | | if (abs(z*rl).ge.dl/2.0.or.r*rl.ge.d/2.0) then ! ������� ��������� |
| 1932 | | ! ��������� �� ������ ������ |
| 1933 | | write(*,*) 'out',x*rl,y*rl,z*rl |
| 1934 | | stop |
| 1935 | | else |
| 1936 | | endif |
| 1937 | | |
| 1938 | | return |
| 1939 | | end |
| 1940 | | |
| 1941 | | |
| 1942 | | }}} |
| 1943 | | |
| 1944 | | |
| 1945 | | == Console30.f90 == |
| 1946 | | {{{ |
| 1947 | | #!fortran |
| 1948 | | ! Osc_rk_0.f90 |
| 1949 | | ! |
| 1950 | | ! Lab #3 |
| 1951 | | ! metod Runge-Kuta. Oscillator. |
| 1952 | | |
| 1953 | | external fct, out |
| 1954 | | real aux(8,2) |
| 1955 | | common /a/ dt, k, n, vm, A, om |
| 1956 | | |
| 1957 | | real :: pr(5)=(/0., 2*3.14159*20., 2*3.14159/50, .0001, .0/) |
| 1958 | | real :: u(2) = (/0., 0.5/) |
| 1959 | | real :: du(2) = (/0.5, 0.5/) |
| 1960 | | integer :: nd = 2 |
| 1961 | | real :: dt = 2*3.14159265 |
| 1962 | | ! real :: lam = 0.1 |
| 1963 | | real :: t |
| 1964 | | real :: om=1 |
| 1965 | | A=2.0 |
| 1966 | | vm=A*om |
| 1967 | | n = 1 |
| 1968 | | k = 1 |
| 1969 | | u(1)=vm/vm |
| 1970 | | u(2)=0 |
| 1971 | | |
| 1972 | | open (unit=2, file = 'osc_rk.dat', status='unknown') |
| | 1571 | open (unit=2, file = 'res_autores.dat', status='unknown') |
| 2167 | | program heat1 |
| 2168 | | |
| 2169 | | implicit none |
| 2170 | | |
| 2171 | | ! Variables |
| 2172 | | real a,b,c,d,dx,dt,x_i,t_j |
| 2173 | | integer n,m,i,j |
| 2174 | | |
| 2175 | | real, allocatable:: U(:,:) |
| 2176 | | |
| 2177 | | open(10,file='result_out1.txt') |
| 2178 | | a=1 |
| 2179 | | b=4 |
| 2180 | | c=1 |
| 2181 | | d=15 |
| 2182 | | write(0,*) "vvedite melkost razbijenija po x" |
| 2183 | | read(*,*) n |
| 2184 | | |
| 2185 | | ! do i=1,n |
| 2186 | | |
| 2187 | | write(0,*) "vvedite melkost razbijenija po t" |
| 2188 | | read(*,*) m |
| 2189 | | dx=(b-a)/n |
| 2190 | | dt=(d-c)/m |
| 2191 | | allocate(U(n,m)) |
| 2192 | | |
| 2193 | | |
| 2194 | | do j=1,m ! ��������� ������� |
| 2195 | | t_j=j*dt |
| 2196 | | U(1,j)=3 |
| 2197 | | U(n,j)=1 |
| 2198 | | end do |
| 2199 | | |
| 2200 | | do i=2,n-1 ! ��������� ������� (������� ����� �� ������, �.�. ���� ������ ���������) |
| 2201 | | x_i=i*dx |
| 2202 | | U(i,1)=1 |
| 2203 | | end do |
| 2204 | | |
| 2205 | | |
| 2206 | | ! �������� ���� |
| 2207 | | do j=1,m-1 ! ���� �� ������� |
| 2208 | | do i=2,n-1 ! ���� �� ������������ |
| 2209 | | U(i,j+1)=U(i,j)+0.005*(dt/(dx)**2)*(U(i+1,j)-2*U(i,j)+U(i-1,j)) |
| 2210 | | print *,i,j+1,U(i,j+1) |
| 2211 | | end do |
| 2212 | | end do |
| 2213 | | |
| 2214 | | |
| 2215 | | !print *, x_i |
| 2216 | | !end do |
| 2217 | | |
| 2218 | | !do j=1,m |
| 2219 | | |
| 2220 | | |
| 2221 | | |
| 2222 | | !print *, t_j |
| 2223 | | |
| 2224 | | |
| 2225 | | do i=1,n |
| 2226 | | write(10,*) i*dx,U(i,m/100),U(i,m/2),U(i,m) |
| 2227 | | enddo |
| 2228 | | |
| 2229 | | |
| 2230 | | end program heat1 |
| 2231 | | |
| 2232 | | }}} |
| 2233 | | |
| 2234 | | == Console32.f90 == |
| 2235 | | {{{ |
| 2236 | | #!fortran |
| 2237 | | ! Osc_rk_0.f90 |
| 2238 | | ! |
| 2239 | | ! Lab #3 |
| 2240 | | ! metod Runge-Kuta. Oscillator. |
| | 1770 | ! Using metod Runge-Kuta |
| 2472 | | |
| | 2003 | ! Using Boris method get the equations of the charge particle motion. And analyze the ECR |
| | 2004 | !(electron cyclotron resonance) phenomenon in parabolic approximation of the magnetic |
| | 2005 | !field (mirror trap) for different input values |
| | 2006 | |
| | 2007 | real :: ez = 4.8e-10, c=3.0e10, me=9.1e-28, f=2.4e09, pi=3.14159265 |
| | 2008 | |
| | 2009 | common/a/ gx(250),gy(250),x,y,z,ux,uy,uz,rl,gm,tp,pi,dt,cl2,al,dl,d |
| | 2010 | |
| | 2011 | |
| | 2012 | open (unit=1, file = 'input_t.dat') |
| | 2013 | open (unit=2, file = 'res.dat') |
| | 2014 | ! |
| | 2015 | ! |
| | 2016 | call cpu_time(start) |
| | 2017 | ! |
| | 2018 | read(1,*) kt,kd,E,al,R,B00,x,y,z,W0,fi |
| | 2019 | write(2,1) kt,kd,E,al,R,B00,x,y,z,W0,fi |
| | 2020 | 1 format('kt='I7,2x,'kd=',I3,2x,'E(kV/cm)=',f4.1,2x,'al=',e10.3,2x, & |
| | 2021 | 'R=',f5.3,2x,'B00(%)=',f8.5/'x(cm) =',f4.1,2x,'y(cm) =',f4.1,2x, & |
| | 2022 | 'z(cm)=',f4.1,2x,'W0(eV)=',e10.3,2x,'fi=',f5.1) |
| | 2023 | 2 format('g0=',e10.3,2x,'B0=',f6.1,2x,'cl=',e10.3,2x,'rl =',f6.2/ & |
| | 2024 | 'wmax=',e10.3,2x,'v0=',e10.3,2x,'w00=',e10.3,2x,'rc=',e10.3) |
| | 2025 | |
| | 2026 | pi2=2.0*pi |
| | 2027 | |
| | 2028 | DL=8.0 |
| | 2029 | D=12.0 |
| | 2030 | fi=fi/180.*pi |
| | 2031 | |
| | 2032 | v0=sqrt(1.-1./(1.+w0/511000.)**2) |
| | 2033 | |
| | 2034 | write(*,*) v0*3.0e8 |
| | 2035 | U0=v0/sqrt(1.0-v0**2) |
| | 2036 | W00=511000.*(sqrt(1.0+u0**2)-1.0) |
| | 2037 | om=2.0*pi*f |
| | 2038 | rl=c/om |
| | 2039 | zm=dl/2.0 |
| | 2040 | cl=(zm/rl)/sqrt(R-1.0) |
| | 2041 | cl2=cl*cl |
| | 2042 | zm=zm/rl |
| | 2043 | |
| | 2044 | E=E*1.0e05/3.0e04 |
| | 2045 | g0=ez*E/(me*c*om) |
| | 2046 | B0=me*c*om/ez |
| | 2047 | wmax=511.0*2.0*g0**(2.0/3.0) |
| | 2048 | rc=v0*3.0e10/om |
| | 2049 | |
| | 2050 | ! B0=875 |
| | 2051 | ! B=875 |
| | 2052 | write(2,2) g0, B0, cl, rl, wmax, v0, w00, rc |
| | 2053 | B=B/B0 |
| | 2054 | x=x/rl |
| | 2055 | y=y/rl |
| | 2056 | z=z/rl |
| | 2057 | ux=u0*sin(fi) |
| | 2058 | uy=u0*cos(fi) |
| | 2059 | uz=0. |
| | 2060 | km=0. |
| | 2061 | kp=0 |
| | 2062 | |
| | 2063 | m=250 |
| | 2064 | dt=2.*pi/m |
| | 2065 | |
| | 2066 | |
| | 2067 | do i=1,m |
| | 2068 | gx(i)=-g0*cos(pi2*(i-1)/m)*dt/2.0 |
| | 2069 | gy(i)=-g0*sin(pi2*(i-1)/m)*dt/2.0 |
| | 2070 | end do |
| | 2071 | |
| | 2072 | write(2,*) 'wmax=', 2.*g0**(2./3.)*511. |
| | 2073 | wm=0 |
| | 2074 | |
| | 2075 | |
| | 2076 | do k=1,kt |
| | 2077 | l=k-kp |
| | 2078 | tm=k*dt |
| | 2079 | |
| | 2080 | tp=-(1.+b00)*dt/2. |
| | 2081 | call motion(l) |
| | 2082 | if (k.eq.km+kd) then |
| | 2083 | w=(gm-1.0)*511.0 |
| | 2084 | write(2,3) tm/(2.*pi), x*rl,y*rl,z*rl, w |
| | 2085 | |
| | 2086 | km=km+kd |
| | 2087 | else |
| | 2088 | end if |
| | 2089 | if (k.eq.kp+m) then |
| | 2090 | kp=kp+m |
| | 2091 | else |
| | 2092 | end if |
| | 2093 | end do |
| | 2094 | 3 format(7f12.5) |
| | 2095 | |
| | 2096 | |
| | 2097 | call cpu_time(finish) |
| | 2098 | write(2,*) 'cpu-time =', finish-start |
| | 2099 | end |
| | 2100 | |
| | 2101 | subroutine motion(l) |
| | 2102 | common/a/ gx(250),gy(250),x,y,z,ux,uy,uz,rl,gm,tp,pi,dt,cl2,al,dl,d |
| | 2103 | |
| | 2104 | |
| | 2105 | |
| | 2106 | r = sqrt(x*x + y*y) |
| | 2107 | bxp=-x*z/cl2 |
| | 2108 | byp=-y*z/cl2 |
| | 2109 | bzp=1.0+z*z/cl2-r*r/(2.*cl2) |
| | 2110 | |
| | 2111 | ! bxp=0.0 |
| | 2112 | ! byp=0.0 |
| | 2113 | ! bzp=1.0 |
| | 2114 | |
| | 2115 | u=sqrt(ux**2+uy**2) |
| | 2116 | |
| | 2117 | !Boris's scheme of partical motion |
| | 2118 | uxm = ux + gx(l) |
| | 2119 | uym = uy + gy(l) |
| | 2120 | uzm = uz |
| | 2121 | |
| | 2122 | gmn = sqrt(1 + uxm*uxm + uym*uym + uzm*uzm) |
| | 2123 | |
| | 2124 | tg = tp/gmn |
| | 2125 | tx = tg * bxp |
| | 2126 | ty = tg * byp |
| | 2127 | tz = tg * bzp |
| | 2128 | |
| | 2129 | uxr = uxm + uym*tz - uzm*ty |
| | 2130 | uyr = uym + uzm*tx - uxm*tz |
| | 2131 | uzr = uzm + uxm*ty - uym*tx |
| | 2132 | gmn = sqrt(1 + uxm*uxm + uym*uym + uzm*uzm) |
| | 2133 | |
| | 2134 | txyzr= 1.+ tx*tx + ty*ty + tz*tz |
| | 2135 | |
| | 2136 | sx = 2*tx/txyzr |
| | 2137 | sy = 2*ty/txyzr |
| | 2138 | sz = 2*tz/txyzr |
| | 2139 | |
| | 2140 | uxp = uxm + uyr*sz - uzr*sy |
| | 2141 | uyp = uym + uzr*sx - uxr*sz |
| | 2142 | uzp = uzm + uxr*sy - uyr*sx |
| | 2143 | |
| | 2144 | ux = uxp + gx(l) |
| | 2145 | uy = uyp + gy(l) |
| | 2146 | uz = uzp |
| | 2147 | |
| | 2148 | gm = sqrt (1. + ux**2 + uy**2 + uz**2) |
| | 2149 | gt=dt/gm |
| | 2150 | x = x + ux*gt |
| | 2151 | y = y + uy*gt |
| | 2152 | z = z + uz*gt |
| | 2153 | |
| | 2154 | if (abs(z*rl).ge.dl/2.0.or.r*rl.ge.d/2.0) then |
| | 2155 | |
| | 2156 | write(*,*) 'out',x*rl,y*rl,z*rl |
| | 2157 | stop |
| | 2158 | else |
| | 2159 | endif |
| | 2160 | |
| | 2161 | return |
| | 2162 | end |
| | 2163 | |
| | 2164 | |
| | 2165 | }}} |
| | 2166 | |
| | 2167 | |
| | 2168 | == 20. Solving nonlinear equation == |
| | 2169 | {{{ |
| | 2170 | #!fortran |
| | 2171 | !using method Newton-Raphson |
| | 2172 | program heat1 |
| | 2173 | |
| | 2174 | implicit none |
| | 2175 | |
| | 2176 | ! Variables |
| | 2177 | real a,b,c,d,dx,dt,x_i,t_j |
| | 2178 | integer n,m,i,j |
| | 2179 | |
| | 2180 | real, allocatable:: U(:,:) |
| | 2181 | |
| | 2182 | open(10,file='result_out1.txt') |
| | 2183 | a=1 |
| | 2184 | b=4 |
| | 2185 | c=1 |
| | 2186 | d=15 |
| | 2187 | write(0,*) "vvedite melkost razbijenija po x" |
| | 2188 | read(*,*) n |
| | 2189 | |
| | 2190 | ! do i=1,n |
| | 2191 | |
| | 2192 | write(0,*) "vvedite melkost razbijenija po t" |
| | 2193 | read(*,*) m |
| | 2194 | dx=(b-a)/n |
| | 2195 | dt=(d-c)/m |
| | 2196 | allocate(U(n,m)) |
| | 2197 | |
| | 2198 | |
| | 2199 | do j=1,m |
| | 2200 | t_j=j*dt |
| | 2201 | U(1,j)=3 |
| | 2202 | U(n,j)=1 |
| | 2203 | end do |
| | 2204 | |
| | 2205 | do i=2,n-1 |
| | 2206 | x_i=i*dx |
| | 2207 | U(i,1)=1 |
| | 2208 | end do |
| | 2209 | |
| | 2210 | |
| | 2211 | |
| | 2212 | do j=1,m-1 |
| | 2213 | do i=2,n-1 |
| | 2214 | U(i,j+1)=U(i,j)+0.005*(dt/(dx)**2)*(U(i+1,j)-2*U(i,j)+U(i-1,j)) |
| | 2215 | print *,i,j+1,U(i,j+1) |
| | 2216 | end do |
| | 2217 | end do |
| | 2218 | |
| | 2219 | |
| | 2220 | !print *, x_i |
| | 2221 | !end do |
| | 2222 | |
| | 2223 | !do j=1,m |
| | 2224 | |
| | 2225 | |
| | 2226 | |
| | 2227 | !print *, t_j |
| | 2228 | |
| | 2229 | |
| | 2230 | do i=1,n |
| | 2231 | write(10,*) i*dx,U(i,m/100),U(i,m/2),U(i,m) |
| | 2232 | enddo |
| | 2233 | |
| | 2234 | |
| | 2235 | end program heat1 |
| | 2236 | |
| | 2237 | }}} |
| | 2238 | |
| | 2239 | == 21. Poisson equations solver == |
| | 2240 | {{{ |
| | 2241 | #!fortran |
| | 2242 | ! Using swap method in one dimensional case, determine the electric filed of the |
| | 2243 | ! electron layer |
| | 2244 | ! Get the plots of the dependencies between the density and the electric filed with |
| | 2245 | ! coordinate z |