Output configuration

18 views
Skip to first unread message

Scott Pesenti

unread,
Mar 26, 2026, 4:24:20 PMMar 26
to mmc-users
Dear Dr. Fang,

I've been trying to use pmmc, running a simple simulation to understand how to retrieve partial pathlength, detector index and number of scattering events.
Though I appear to have run the simulation correctly, the output dictionary only contains the element 'flux'.

Here's my code:

t = 100
c0 = np.array([0, 0, 0])
c1 = np.array([0, 0, t])
r = 20 # Raggio del cilindro
tsize = 10
maxvol = 10
ndiv = 40
node, _, elem = i2m.meshacylinder(c0, c1, r, tsize, maxvol, ndiv)

cfg = dict(
node=node,
elem=elem[:, 0:4],
elemprop=elem[:, -1],
prop=np.array([[0, 0, 1, 1], [0, 10, 0.9, 1.37]]),
nphoton=1e5,
issrcfrom0=1,
srcpos=np.array([0, r, t/2]),
srcdir=np.array([0, -1, 0]),
detpos=np.array([0, -r, t/2, 1]),
savedetflag='dpk',
tstart=0,
tend=5e-9,
tstep=5e-9,
)

res = pmmc.run(cfg)


The code seems to run and compile correctly, as the output is:

nphoton: 100000
tstart: 0
tstep: 5e-09
tend: 5e-09
srcpos: [0, 20, 50]
srcdir: [0, -1, 0, 0]

However, if I ask 
print(res.keys())

The output is only

dict_keys(['flux']).

Is there anything I'm missing? 
Thank you very much,

Scott Pesenti

Qianqian Fang

unread,
Apr 1, 2026, 11:43:51 AMApr 1
to mmc-...@googlegroups.com, Scott Pesenti

hi Scott,

sorry for the late reply. you will have to add issavedet=1 to your cfg dict. 

in matlab, by requesting two or more output for mmclab, you can get the detp output. 

however, Python is different, it does not have nargout like in matlab, so you will have to explicitly request this output using a dedicated input flag, in this case, issavedet.

similarly, if you want to save the RNG seeds, you will have to add cfg['issaveseed']=1; to get dref output, you must set cfg['issavedref']=1

Qianqian


On 3/26/26 10:40, Scott Pesenti wrote:

You don't often get email from scott.p...@gmail.com. Learn why this is important

--
You received this message because you are subscribed to the Google Groups "mmc-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mmc-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mmc-users/2358fbda-9763-4d71-9356-828cad2d1e82n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages