mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Added some infrastructure for geometry plotting.
This commit is contained in:
parent
ae9ef677cb
commit
02bf501728
7 changed files with 147 additions and 26 deletions
|
|
@ -104,6 +104,7 @@ main.o: mpi_routines.o
|
|||
main.o: output.o
|
||||
main.o: particle_header.o
|
||||
main.o: physics.o
|
||||
main.o: plot.o
|
||||
main.o: source.o
|
||||
main.o: string.o
|
||||
main.o: tally.o
|
||||
|
|
@ -146,6 +147,13 @@ physics.o: search.o
|
|||
physics.o: string.o
|
||||
physics.o: tally.o
|
||||
|
||||
plot.o: constants.o
|
||||
plot.o: error.o
|
||||
plot.o: geometry.o
|
||||
plot.o: geometry_header.o
|
||||
plot.o: global.o
|
||||
plot.o: particle_header.o
|
||||
|
||||
search.o: constants.o
|
||||
search.o: error.o
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ mpi_routines.o \
|
|||
output.o \
|
||||
particle_header.o \
|
||||
physics.o \
|
||||
plot.o \
|
||||
search.o \
|
||||
source.o \
|
||||
source_header.o \
|
||||
|
|
|
|||
|
|
@ -124,6 +124,9 @@ module global
|
|||
real(8) :: weight_cutoff = 0.25
|
||||
real(8) :: weight_survive = 1.0
|
||||
|
||||
! Plotting options
|
||||
logical :: plotting = .false.
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
|
|
|
|||
|
|
@ -78,29 +78,31 @@ contains
|
|||
! neighboring cells for efficient tracking
|
||||
call neighbor_lists()
|
||||
|
||||
! Read cross section summary file to determine what files contain
|
||||
! cross-sections
|
||||
call read_xsdata(path_xsdata)
|
||||
if (.not. plotting) then
|
||||
! Read cross section summary file to determine what files contain
|
||||
! cross-sections
|
||||
call read_xsdata(path_xsdata)
|
||||
|
||||
! With the AWRs from the xsdata, change all material specifications so that
|
||||
! they contain atom percents summing to 1
|
||||
call normalize_ao()
|
||||
! With the AWRs from the xsdata, change all material specifications so that
|
||||
! they contain atom percents summing to 1
|
||||
call normalize_ao()
|
||||
|
||||
! Read ACE-format cross sections
|
||||
call read_xs()
|
||||
! Read ACE-format cross sections
|
||||
call read_xs()
|
||||
|
||||
! Construct unionized energy grid from cross-sections
|
||||
call unionized_grid()
|
||||
call original_indices()
|
||||
! Construct unionized energy grid from cross-sections
|
||||
call unionized_grid()
|
||||
call original_indices()
|
||||
|
||||
! Create tally map
|
||||
call create_tally_map()
|
||||
! Create tally map
|
||||
call create_tally_map()
|
||||
|
||||
! create source particles
|
||||
call initialize_source()
|
||||
! create source particles
|
||||
call initialize_source()
|
||||
end if
|
||||
|
||||
! stop timer for initialization
|
||||
if (master) then
|
||||
if (master .and. (.not. plotting)) then
|
||||
call echo_input()
|
||||
call print_summary()
|
||||
end if
|
||||
|
|
@ -116,8 +118,11 @@ contains
|
|||
|
||||
subroutine read_command_line()
|
||||
|
||||
integer :: argc ! number of command line arguments
|
||||
character(MAX_LINE_LEN) :: pwd ! present working directory
|
||||
integer :: i ! loop index
|
||||
integer :: argc ! number of command line arguments
|
||||
integer :: last_flag ! index of last flag
|
||||
character(MAX_LINE_LEN) :: pwd ! present working directory
|
||||
character(MAX_WORD_LEN) :: argv(10) ! command line arguments
|
||||
|
||||
! Get working directory
|
||||
call GET_ENVIRONMENT_VARIABLE("PWD", pwd)
|
||||
|
|
@ -125,11 +130,25 @@ contains
|
|||
! Check number of command line arguments
|
||||
argc = COMMAND_ARGUMENT_COUNT()
|
||||
|
||||
! Get all command line arguments
|
||||
last_flag = 0
|
||||
do i = 1, argc
|
||||
call GET_COMMAND_ARGUMENT(i, argv(i))
|
||||
|
||||
! Check for flags
|
||||
if (starts_with(argv(i), "-")) then
|
||||
if (argv(i)(2:5) == 'plot') then
|
||||
plotting = .true.
|
||||
end if
|
||||
|
||||
last_flag = i
|
||||
end if
|
||||
end do
|
||||
|
||||
! Determine directory where XML input files are
|
||||
if (argc > 0) then
|
||||
call GET_COMMAND_ARGUMENT(1, path_input)
|
||||
! Need to add working directory if the given path is a relative
|
||||
! path
|
||||
path_input = argv(last_flag + 1)
|
||||
! Need to add working directory if the given path is a relative path
|
||||
if (.not. starts_with(path_input, "/")) then
|
||||
path_input = trim(pwd) // "/" // trim(path_input)
|
||||
end if
|
||||
|
|
|
|||
15
src/main.f90
15
src/main.f90
|
|
@ -7,6 +7,7 @@ program main
|
|||
use mpi_routines, only: synchronize_bank
|
||||
use output, only: message, header, print_runtime
|
||||
use particle_header, only: Particle
|
||||
use plot, only: run_plot
|
||||
use physics, only: transport
|
||||
use tally, only: calculate_keff
|
||||
use source, only: get_source_particle
|
||||
|
|
@ -28,12 +29,16 @@ program main
|
|||
call initialize_run()
|
||||
|
||||
! start problem
|
||||
call run_problem()
|
||||
if (plotting) then
|
||||
call run_plot()
|
||||
else
|
||||
call run_problem()
|
||||
|
||||
! show timing statistics
|
||||
call timer_stop(time_total)
|
||||
if (master) call print_runtime()
|
||||
if (master) call write_tallies()
|
||||
! show timing statistics
|
||||
call timer_stop(time_total)
|
||||
if (master) call print_runtime()
|
||||
if (master) call write_tallies()
|
||||
end if
|
||||
|
||||
! deallocate arrays
|
||||
call free_memory()
|
||||
|
|
|
|||
75
src/plot.f90
Normal file
75
src/plot.f90
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
module plot
|
||||
|
||||
use constants
|
||||
use error, only: fatal_error
|
||||
use geometry, only: find_cell, dist_to_boundary, cross_surface, &
|
||||
cross_lattice
|
||||
use geometry_header, only: Universe, BASE_UNIVERSE
|
||||
use global
|
||||
use particle_header, only: Particle
|
||||
|
||||
implicit none
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
! RUN_PLOT
|
||||
!===============================================================================
|
||||
|
||||
subroutine run_plot()
|
||||
|
||||
end subroutine run_plot
|
||||
|
||||
!===============================================================================
|
||||
! TRANSPORT encompasses the main logic for moving a particle through geometry.
|
||||
!===============================================================================
|
||||
|
||||
subroutine transport_no_collision(p)
|
||||
|
||||
type(Particle), pointer :: p
|
||||
|
||||
integer :: surf ! surface which particle is on
|
||||
integer :: last_cell ! most recent cell particle was in
|
||||
real(8) :: distance ! distance particle travels
|
||||
logical :: found_cell ! found cell which particle is in?
|
||||
logical :: in_lattice ! is surface crossing in lattice?
|
||||
character(MAX_LINE_LEN) :: msg ! output/error message
|
||||
type(Universe), pointer :: univ
|
||||
|
||||
if (p % cell == 0) then
|
||||
univ => universes(BASE_UNIVERSE)
|
||||
call find_cell(univ, p, found_cell)
|
||||
|
||||
! if particle couldn't be located, print error
|
||||
if (.not. found_cell) then
|
||||
write(msg, '(A,3ES11.3)') &
|
||||
"Could not locate cell for particle at: ", p % xyz
|
||||
call fatal_error(msg)
|
||||
end if
|
||||
end if
|
||||
|
||||
! find energy index, interpolation factor
|
||||
do while (p % alive)
|
||||
|
||||
! Find the distance to the nearest boundary
|
||||
call dist_to_boundary(p, distance, surf, in_lattice)
|
||||
|
||||
! Advance particle
|
||||
p%xyz = p%xyz + distance * p%uvw
|
||||
p%xyz_local = p%xyz_local + distance * p%uvw
|
||||
|
||||
last_cell = p % cell
|
||||
p % cell = 0
|
||||
if (in_lattice) then
|
||||
p % surface = 0
|
||||
call cross_lattice(p)
|
||||
else
|
||||
p % surface = surf
|
||||
call cross_surface(p, last_cell)
|
||||
end if
|
||||
|
||||
end do
|
||||
|
||||
end subroutine transport_no_collision
|
||||
|
||||
end module plot
|
||||
10
src/xml-fortran/templates/plot_t.xml
Normal file
10
src/xml-fortran/templates/plot_t.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<template>
|
||||
|
||||
<options rootname="plot" />
|
||||
|
||||
<variable name="origin_" tag="origin" type="double-array" />
|
||||
<variable name="width_" tag="width" type="double-array" />
|
||||
<variable name="basis_" tag="basis" type="word" length="3" />
|
||||
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue