Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mcxpreview #98

Closed
wants to merge 5 commits into from
Closed

Update mcxpreview #98

wants to merge 5 commits into from

Conversation

kaoben2731
Copy link

Not rotate the quadrilateral by srcdir while using planar or pattern source type.

For example, in the demo_photon_sharing.m, if I set the srcparam1 and srcparam2 like that, the preview will be not consistent with the setting.
image
But the simulation result will be consistent with the setting.
image

After change a little bit in mcxpreview.m, the preview will be consistent with the setting.
image

@fangq
Copy link
Owner

fangq commented Jul 25, 2020

hi @kaoben2731, thanks for the PR. sorry for the delay for reviewing this.

the mcxpreview fix looks good - can you just change it to

            hsrcarea=plotmesh(nrec+repmat(srcpos(:)',[4,1]), {[1 2 3 4 1]});

basically, no rotation is needed in these sources.

I would like to ask you about the later two commits - what is the "anglepattern" source? how is it different from a regular pattern?

@kaoben2731
Copy link
Author

Thanks for your reply and suggestion.

I didn't ment to ask you to pull the 2 anglepattern commits, I just forgot to make a new branch for them.

The angle pattern is a user-specified pattern on the angle power distribution.

I used MCX to simulate a LED light source, and I tired cone source and zGaussian source.
I have the angle profile of the LED, and it's unit is power/per unit solid angle
image

I change it to the total power comes out from certain angle by multiple it by sin(angle)
image

But it is not similar to either cone (which I believe is sin(angle) in the setting angle range) or zGaussian (which I believe is the Gaussian distribution).

So I want to make a source which can do any kinds of angle profile.
I turn the power distribution PDF into CDF
image

Then I make a array of each CDF value and it's corresponding angle value
The interval of CDF value is constant for MCX to easier interpolation.
For example:
image

Then MCX can use the uniform distributed random variable in (0,1] to sample the angle by inverse transform sampling.

A simple simulation result is below,
image

@fangq
Copy link
Owner

fangq commented Jul 26, 2020

thanks for sharing this - if the angle-dependent source still needs more work, and is not ready to be shared, I suggest you to close this PR, refork from my mcx repo to a special branch, just patch mcxpreview.m, and create a new PR. alternatively, I will be happy to manually patch mcxpreview.m.

@kaoben2731
Copy link
Author

Thanks for your suggestion. I had created a new PR.

Also, I'd like to know if you think the "anglepattern source" is needed?
If it is, what thing is need for it to be accepted?
I think of (1) an update in mcxlab/README.txt for the explain
(2) maybe a demo script for how to use it

Thanks a lot.

@kaoben2731 kaoben2731 closed this Jul 26, 2020
@fangq
Copy link
Owner

fangq commented Jul 26, 2020

Also, I'd like to know if you think the "anglepattern source" is needed?

I absolutely welcome contributions from users and I am sure such a feature, if fully tested, will benefit the greater user community.

what thing is need for it to be accepted?
I think of (1) an update in mcxlab/README.txt for the explain
(2) maybe a demo script for how to use it

both 1/2, but on top of that, I want to first make sure the feature is fully implemented and tested - what is the status of this development? specifically, how do you plan to add the additional user input, such as the user-defined CDF (? or PDF?), which part of the GPU memory that you plan to store such information?

generally, I implement a feature both for mcx binary and mcxlab, that means one needs to update mcx_utils.c/h to add the json input support and cfg data structure modification, and also modify mcxlab.cpp to accept matlab inputs. Please take time to implement such feature, and I will be happy to provide suggestions if you are interested in sharing such change to upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants