From 02bf5017288f31be9e7377be2efbe05803abf1c0 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sun, 16 Oct 2011 14:43:29 -0400 Subject: [PATCH] Added some infrastructure for geometry plotting. --- src/DEPENDENCIES | 8 +++ src/OBJECTS | 1 + src/global.f90 | 3 ++ src/initialize.f90 | 61 ++++++++++++++-------- src/main.f90 | 15 ++++-- src/plot.f90 | 75 ++++++++++++++++++++++++++++ src/xml-fortran/templates/plot_t.xml | 10 ++++ 7 files changed, 147 insertions(+), 26 deletions(-) create mode 100644 src/plot.f90 create mode 100644 src/xml-fortran/templates/plot_t.xml diff --git a/src/DEPENDENCIES b/src/DEPENDENCIES index 2a0bd27635..16c4fa7793 100644 --- a/src/DEPENDENCIES +++ b/src/DEPENDENCIES @@ -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 diff --git a/src/OBJECTS b/src/OBJECTS index 536508d01e..db515d0b08 100644 --- a/src/OBJECTS +++ b/src/OBJECTS @@ -26,6 +26,7 @@ mpi_routines.o \ output.o \ particle_header.o \ physics.o \ +plot.o \ search.o \ source.o \ source_header.o \ diff --git a/src/global.f90 b/src/global.f90 index 13529f61af..9889ea9513 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -124,6 +124,9 @@ module global real(8) :: weight_cutoff = 0.25 real(8) :: weight_survive = 1.0 + ! Plotting options + logical :: plotting = .false. + contains !=============================================================================== diff --git a/src/initialize.f90 b/src/initialize.f90 index ee6f1c6818..cfe4ca5151 100644 --- a/src/initialize.f90 +++ b/src/initialize.f90 @@ -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 diff --git a/src/main.f90 b/src/main.f90 index 67a8aa81fb..9bbb16c6a4 100644 --- a/src/main.f90 +++ b/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() diff --git a/src/plot.f90 b/src/plot.f90 new file mode 100644 index 0000000000..4add38fc42 --- /dev/null +++ b/src/plot.f90 @@ -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 diff --git a/src/xml-fortran/templates/plot_t.xml b/src/xml-fortran/templates/plot_t.xml new file mode 100644 index 0000000000..d13615fa32 --- /dev/null +++ b/src/xml-fortran/templates/plot_t.xml @@ -0,0 +1,10 @@ + +