EGSnrc icon indicating copy to clipboard operation
EGSnrc copied to clipboard

Bug in egs_input.cpp that effects egs_glib

Open Apelova opened this issue 2 months ago • 2 comments

When trying to import a previously defined geometry using egs_glib quite a nerve wracking Bug occurs if there is a space before the line break.

I attached a simple Input-File for the usercode tutor7pp (and a geometry-file) that demonstrates the issue at hand (just comment/uncomment the lines 10 and 11 and make sure that sphere.geom is in the correct directory). It took me quite some time to realize what was happening when this bug first occurred, but after checking the source code, I recognized that the code only clears spaces in front of the file name to be imported.

The Bug can easily be fixed by inserting the line below in line 892 of egs_input.cpp

value = (*(value.end()-1) == ' ') ? string(value.begin(), value.end()-1) : value ;

Tutor7pp Input File

##############################################################
# Tutor7pp Input-File to reproduce Bug in egs_input.cpp
##############################################################

:start geometry definition:
	:start geometry:
		library = egs_glib
		name = imported_sphere 
		#--- to reproduce the bug comment/uncomment the two lines below
		include file = sphere.geom#<--- works
		#include file = sphere.geom #<--- doesn't work 
	:stop geometry:

	simulation geometry = imported_sphere
:stop geometry definition:




###########################################
:start source definition:
    :start source:
        library = egs_parallel_beam
        name = the_source
        :start shape:
            type = point
            position = 0 0 1e-7
        :stop shape:
        direction = 0 0 1
        charge = -1
        :start spectrum:
            type = monoenergetic
            energy = 20.0
        :stop spectrum:
    :stop source:

    simulation source = the_source
:stop source definition:

######################################## Run control
:start run control:
    ncase = 100
:stop run control:

Geometry File

:start geometry definition:
	 :start geometry:
        name     = Sphere
        library  = egs_spheres
        midpoint = 0 0 0
        radii    = 2
        :start media input:
            media = H2O521ICRU
            set medium = 0 0
        :stop media input:
    :stop geometry:
	
	simulation geometry = Sphere
:stop geometry definition:

Operating system

  • [x ] Linux

EGSnrc version 2023

Apelova avatar May 01 '24 19:05 Apelova