/********************************************************************************************************************************************** * * Basic SANS * * Source 'rot_t3m-25_sp': normalized to 2.2408e+14 p/pulse and 1.300 GeV * * E = 81.8047 / lambda^2 * E = 0.8181 meV = 10 Angstroem * E = 20.45 meV = 2 Angstroem * * E = 9.09 meV = 3.0 Angstroem * E = 13.09 meV = 2.5 Angstroem (spectral brightness of moderator: approx. 5.5e+14 n/sr/eV/pulse) * E = 4.73 meV = 4.16 Angstroem (spectral peak brightness of moderator at 4.16 Angstroem (4.73meV: 8.3423e+14 n/sr/eV/pulse) * ********************************************************************************************************************************************** */ DEFINE INSTRUMENT BER_Sans_optimize(lambda_max = 9.418, opticsStart = 0.843, apt_0_size = 0.0801, guide_0_Start = 1.026, guide_0_End = 2.331, guide_0_size_1 = 0.0331, guide_0_size_2 = 0.0507, guide_0_m = 6.223, apt_1_size = 0.0724, guide_1_Start = 2.389, guide_1_End = 14.001, guide_1_size = 0.0469, guide_1_f1 = 2.298, guide_1_f2 = 1857.7, guide_1_m = 3.04, apt_2_size = 0.2838, guide_2_Start = 14.35, guide_2_End = 29.21, guide_2_size = 0.108, guide_2_f1 = 3590.2, guide_2_f2 = 1.506, guide_2_m = 6.549, apt_3_size = 0.0930, sample_pos = 30.0, sample_size = 0.01, detector_pos = 33.0) DECLARE %{ double taperLength; double lambda_min; double guide_1_length, guide_2_length, SD; double detectorRadius = 1.0; double E_low, E_high; double apt_0_width, apt_0_height, apt_1_width, apt_1_height, apt_2_width, apt_2_height, apt_3_width, apt_3_height; double apt_0_pos, apt_1_pos, apt_2_pos, apt_3_pos; double sample_n; // Function used to determine the number of datapoints in the input file int CountLines(FILE* File) { // Declarations double Dummy1; double Dummy2; char Line[256]; int NumberOfDatapoints = 0; // I/O while (fgets(Line, sizeof(Line), File) != NULL) { if (sscanf(Line, "%lf %lf", &Dummy1, &Dummy2) == 2) { ++NumberOfDatapoints; } } return NumberOfDatapoints; } // Function used to extract the scattering profile from a given curve int LoadCurve(char Filename[], double** Q, double** I) { // Declarations FILE* File; int i = 0; int NumberOfDatapoints; char Line[256]; double *IntensityArray; double *qArray; // Reading file if ((File = fopen(Filename, "r")) == 0) { printf("Cannot open file: %s...\n", Filename); exit(0); } NumberOfDatapoints = CountLines(File); qArray = (double *) calloc(NumberOfDatapoints, sizeof(double)); IntensityArray = (double *) calloc(NumberOfDatapoints, sizeof(double)); rewind(File); while (i < NumberOfDatapoints && fgets(Line, sizeof(Line), File) != NULL) { if (sscanf(Line, "%lf %lf", &qArray[i], &IntensityArray[i]) == 2) { ++i; } } *I = IntensityArray; *Q = qArray; return NumberOfDatapoints; } %} INITIALIZE %{ // until otherwise required I use the smallest lambda_min conceivable... // ========================================================================= lambda_min = (detector_pos * lambda_max - 3956.0 / 15.0) / detector_pos; if (lambda_min < 0.1) lambda_min = 0.1; taperLength = guide_0_End - guide_0_Start; guide_1_length = guide_1_End - guide_1_Start; guide_2_length = guide_2_End - guide_2_Start; SD = detector_pos - sample_pos; E_low = (9.045 / lambda_max) * (9.045 / lambda_max); E_high = (9.045 / lambda_min) * (9.045 / lambda_min); apt_0_width = apt_0_height = apt_0_size; apt_0_pos = opticsStart; apt_1_width = apt_1_height = apt_1_size; apt_1_pos = guide_0_End + 0.001; apt_2_width = apt_2_height = apt_2_size; apt_2_pos = guide_1_End + 0.001; apt_3_width = apt_3_height = apt_3_size; apt_3_pos = guide_2_End + 0.001; %} TRACE COMPONENT origin = Progress_bar() AT (0, 0, 0) ABSOLUTE COMPONENT arm_source = Arm( ) AT (0, 0, 0) RELATIVE origin // ========================================================================================================= COMPONENT Source = SNS_source_mod(filename = "/home/cwl/McStas_projects/BER_SANS/source_rot_t3m-25_sp.dat", radius = 0.015, dist = guide_1_Start, focus_xw = 1.01 * apt_0_width, focus_yh = 1.01 * apt_0_height, Emin = E_low, Emax = E_high, Anorm = 0.000707) AT (0,0,0) RELATIVE origin // Aperture at entrance to straight tapered section... // ================================================================= COMPONENT Apt_0 = Slit(xwidth = apt_0_width, yheight = apt_0_height) AT (0, 0, apt_0_pos) RELATIVE origin // Tapered guide... // ========================================================================================================== COMPONENT taperedGuide = Guide(w1 = guide_0_size_1, h1 = guide_0_size_1, w2 = guide_0_size_2, h2 = guide_0_size_2, l = taperLength, m = guide_0_m) AT (0, 0, guide_0_Start) RELATIVE origin // Aperture at entrance to focusing section... // ================================================================= COMPONENT Apt_1 = Slit(xwidth = apt_1_width, yheight = apt_1_height) AT (0, 0, apt_1_pos) RELATIVE origin // 1st half of elliptical guide... // ======================================================================================================== COMPONENT focussingGuide_1 = Guide_tapering(option = "elliptical", w1 = guide_1_size, h1 = guide_1_size, l = guide_1_length, linw = guide_1_f1, loutw = guide_1_f2, linh = guide_1_f1, louth = guide_1_f2, mx = guide_1_m, my = guide_1_m) AT (0, 0, guide_1_Start) RELATIVE origin // Aperture at center to focusing section... // ================================================================= COMPONENT Apt_2 = Slit(xwidth = apt_2_width, yheight = apt_2_height) AT (0, 0, apt_2_pos) RELATIVE origin //COMPONENT guide_center_psd = PSD_monitor(nx = 127, ny = 127, // filename = "Guide_center.dat", // xwidth = 1.05 * apt_width_2, yheight = 1.05 * apt_height_2, // //xwidth = 0.06, yheight = 0.06, // restore_neutron = 1) //AT (0, 0, apt_pos_2 + 0.001) RELATIVE origin // 2nd half of elliptical guide... // =============================== COMPONENT focussingGuide_2 = Guide_tapering(option = "elliptical", w1 = guide_2_size, h1 = guide_2_size, l = guide_2_length, linw = guide_2_f1, loutw = guide_2_f2, linh = guide_2_f1, louth = guide_2_f2, mx = guide_2_m, my = guide_2_m) AT (0, 0, guide_2_Start) RELATIVE origin COMPONENT Apt_3 = Slit(xwidth = apt_3_width, yheight = apt_3_height) AT (0, 0, apt_3_pos) RELATIVE origin // Monitor beam divergence at sample position... // (we want the sensitive area be identical to the sample area!) // ============================================================= COMPONENT sample_Div = Divergence_monitor(nh = 127, nv = 127, filename = "Sample_divergence.dat", xwidth = sample_size, yheight = sample_size, maxdiv_h = 0.25, maxdiv_v = 0.25, restore_neutron = 1) AT (0, 0, sample_pos - 0.01) RELATIVE origin COMPONENT sample_Div_2 = Divergence_monitor(nh = 127, nv = 127, filename = "Sample_divergence_2.dat", xwidth = sample_size, yheight = sample_size, maxdiv_h = 2.5, maxdiv_v = 2.5, restore_neutron = 1) AT (0, 0, sample_pos - 0.009) RELATIVE origin COMPONENT sample_apt = Slit(xwidth = sample_size, yheight = sample_size) AT (0, 0, sample_pos - 0.008) RELATIVE origin COMPONENT sample_psd = PSD_monitor(nx = 127, ny = 127, filename = "Sample_psd.dat", xwidth = 1.05 * sample_size, yheight = 1.05 * sample_size, restore_neutron = 1) AT (0, 0, sample_pos - 0.007) RELATIVE origin // Multiple samples... // =================== COMPONENT a0 = Arm() AT (0, 0, sample_pos) RELATIVE origin EXTEND %{ sample_n = 0; %} SPLIT 5 COMPONENT a1 = Arm() AT (0, 0, 0) RELATIVE a0 EXTEND %{ sample_n++; %} // // ==========> Samples <============ // // // sample #1: flatline_1.dat // ===================================================================================================== COMPONENT GK_MD_sim_1 = SANSCurve_1(DeltaRho = 1.0e-14, Volume = 1000.0, Concentration = 0.01, AbsorptionCrosssection = 0.0, xwidth = sample_size, yheight = sample_size, zdepth = 0.005, SampleToDetectorDistance = SD, DetectorRadius = 1.0, FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/flatLine_1.dat") WHEN (sample_n == 1) AT (0, 0, 0) RELATIVE a1 // sample #2: 1_Apo_Guanylate_kinase_theoretical_SANS.dat // ===================================================================================================== COMPONENT GK_MD_sim_2 = SANSCurve_2(DeltaRho = 1.0e-14, Volume = 1000.0, Concentration = 0.01, AbsorptionCrosssection = 0.0, xwidth = sample_size, yheight = sample_size, zdepth = 0.005, SampleToDetectorDistance = SD, DetectorRadius = 1.0, FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/Apo_Guanylate_kinase_theoretical_SANS.dat") WHEN (sample_n == 2) AT (0, 0, 0) RELATIVE a1 // sample #3: Guanylate_kinase_GMP_theoretical_SANS.dat // ===================================================================================================== COMPONENT GK_MD_sim_3 = SANSCurve_3(DeltaRho = 1.0e-14, Volume = 1000.0, Concentration = 0.01, AbsorptionCrosssection = 0.0, xwidth = sample_size, yheight = sample_size, zdepth = 0.005, SampleToDetectorDistance = SD, DetectorRadius = 1.0, FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/Guanylate_kinase_GMP_theoretical_SANS.dat") WHEN (sample_n == 3) AT (0, 0, 0) RELATIVE a1 // sample #4: cel7a_compact.dat // ===================================================================================================== COMPONENT GK_MD_sim_4 = SANSCurve_4(DeltaRho = 1.0e-14, Volume = 1000.0, Concentration = 0.01, AbsorptionCrosssection = 0.0, xwidth = sample_size, yheight = sample_size, zdepth = 0.005, SampleToDetectorDistance = SD, DetectorRadius = 1.0, FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/cel7a_compact.dat") WHEN (sample_n == 4) AT (0, 0, 0) RELATIVE a1 // sample #5: /home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/cel7a_extended.dat // ===================================================================================================== COMPONENT GK_MD_sim_5 = SANSCurve_5(DeltaRho = 1.0e-14, Volume = 1000.0, Concentration = 0.01, AbsorptionCrosssection = 0.0, xwidth = sample_size, yheight = sample_size, zdepth = 0.005, SampleToDetectorDistance = SD, DetectorRadius = 1.0, FileWithCurve = "/home/cwl/McStas_projects/BER_SANS/BER_SANS_optimize_elliptical_discrimination/samples/cel7a_extended.dat") WHEN (sample_n == 5) AT (0, 0, 0) RELATIVE a1 // // ==========> Monitors and Detectors <============ // // q monitor #1... // =============== COMPONENT sansqmonitor_1 = SANSQMonitor(LambdaMin = 1.9, RFilename = "RDetector_1", qFilename = "QDetector_1", NumberOfBins = 1025, RadiusDetector = detectorRadius, DistanceFromSample = SD, restore_neutron = 0) WHEN (sample_n == 1) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1 // q monitor #2... // =============== COMPONENT sansqmonitor_2 = SANSQMonitor(LambdaMin = 1.9, RFilename = "RDetector_2", qFilename = "QDetector_2", NumberOfBins = 1025, RadiusDetector = detectorRadius, DistanceFromSample = SD, restore_neutron = 0) WHEN (sample_n == 2) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1 // q monitor #3... // =============== COMPONENT sansqmonitor_3 = SANSQMonitor(LambdaMin = 1.9, RFilename = "RDetector_3", qFilename = "QDetector_3", NumberOfBins = 1025, RadiusDetector = detectorRadius, DistanceFromSample = SD, restore_neutron = 0) WHEN (sample_n == 3) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1 // q monitor #4... // =============== COMPONENT sansqmonitor_4 = SANSQMonitor(LambdaMin = 1.9, RFilename = "RDetector_4", qFilename = "QDetector_4", NumberOfBins = 1025, RadiusDetector = detectorRadius, DistanceFromSample = SD, restore_neutron = 0) WHEN (sample_n == 4) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1 // q monitor #5... // =============== COMPONENT sansqmonitor_5 = SANSQMonitor(LambdaMin = 1.9, RFilename = "RDetector_5", qFilename = "QDetector_5", NumberOfBins = 1025, RadiusDetector = detectorRadius, DistanceFromSample = SD, restore_neutron = 0) WHEN (sample_n == 5) AT (0, 0, (detector_pos - sample_pos + 0.004)) RELATIVE a1 FINALLY %{ %} END