|
1 | 1 | import viennaps as ps |
2 | 2 | import viennals as ls |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import numpy as np |
3 | 5 |
|
4 | 6 | ps.setDimension(2) |
5 | 7 | ls.setDimension(2) |
6 | 8 |
|
7 | | -params = ps.readConfigFile("config.txt") |
8 | | -geometry = ps.Domain() |
9 | | - |
10 | | -# Create the geometry |
11 | | -boundaryCons = [ |
12 | | - ps.BoundaryType.REFLECTIVE_BOUNDARY, |
13 | | - ps.BoundaryType.INFINITE_BOUNDARY, |
14 | | -] |
15 | | -gridDelta = params["gridDelta"] |
16 | | -bounds = [ |
17 | | - 0.0, |
18 | | - params["openingWidth"] / 2.0 + params["xPad"] + params["gapLength"], |
19 | | - -gridDelta, |
20 | | - params["openingDepth"] + params["gapHeight"] + gridDelta, |
21 | | -] |
22 | | - |
23 | | -substrate = ls.Domain(bounds, boundaryCons, gridDelta) |
24 | | -normal = [0.0, 1.0] |
25 | | -origin = [0.0, params["openingDepth"] + params["gapHeight"]] |
26 | | -ls.MakeGeometry(substrate, ls.Plane(origin, normal)).apply() |
27 | | - |
28 | | -geometry.insertNextLevelSetAsMaterial(substrate, ps.Material.Si) |
29 | | - |
30 | | -vertBox = ls.Domain(bounds, boundaryCons, gridDelta) |
31 | | -minPoint = [-gridDelta, 0.0] |
32 | | -maxPoint = [ |
33 | | - params["openingWidth"] / 2.0, |
34 | | - params["gapHeight"] + params["openingDepth"] + gridDelta, |
35 | | -] |
36 | | -ls.MakeGeometry(vertBox, ls.Box(minPoint, maxPoint)).apply() |
37 | | - |
38 | | -geometry.applyBooleanOperation(vertBox, ls.BooleanOperationEnum.RELATIVE_COMPLEMENT) |
39 | | - |
40 | | -horiBox = ls.Domain(bounds, boundaryCons, gridDelta) |
41 | | -minPoint = [params["openingWidth"] / 2.0 - gridDelta, 0.0] |
42 | | -maxPoint = [params["openingWidth"] / 2.0 + params["gapLength"], params["gapHeight"]] |
43 | | -ls.MakeGeometry(horiBox, ls.Box(minPoint, maxPoint)).apply() |
44 | | -geometry.applyBooleanOperation(horiBox, ls.BooleanOperationEnum.RELATIVE_COMPLEMENT) |
45 | | - |
46 | | -geometry.saveVolumeMesh("SingleParticleALD_initial") |
47 | | - |
48 | | -geometry.duplicateTopLevelSet(ps.Material.Al2O3) |
49 | | - |
50 | | -gasMFP = ps.constants.gasMeanFreePath( |
51 | | - params["pressure"], params["temperature"], params["diameter"] |
52 | | -) |
53 | | -print("Mean free path: ", gasMFP, " um") |
54 | | - |
55 | | -model = ps.SingleParticleALD( |
56 | | - stickingProbability=params["stickingProbability"], |
57 | | - numCycles=int(params["numCycles"]), |
58 | | - growthPerCycle=params["growthPerCycle"], |
59 | | - totalCycles=int(params["totalCycles"]), |
60 | | - coverageTimeStep=params["coverageTimeStep"], |
61 | | - evFlux=params["evFlux"], |
62 | | - inFlux=params["inFlux"], |
63 | | - s0=params["s0"], |
64 | | - gasMFP=gasMFP, |
65 | | -) |
66 | | - |
67 | | -alpParams = ps.AtomicLayerProcessParameters() |
68 | | -alpParams.pulseTime = params["pulseTime"] |
69 | | -alpParams.coverageTimeStep = params["coverageTimeStep"] |
70 | | -alpParams.numCycles = int(params["numCycles"]) |
71 | | - |
72 | | -rayParams = ps.RayTracingParameters() |
73 | | -rayParams.raysPerPoint = int(params["numRaysPerPoint"]) |
74 | | - |
75 | | -ALP = ps.Process(geometry, model) |
76 | | -ALP.setParameters(rayParams) |
77 | | -ALP.setParameters(alpParams) |
78 | | -ALP.apply() |
79 | | - |
80 | | -## TODO: Implement MeasureProfile in Python |
81 | | -# MeasureProfile<NumericType, D>(domain, params.get("gapHeight") / 2.) |
82 | | -# .save(params.get<std::string>("outputFile")); |
83 | | - |
84 | | -geometry.saveVolumeMesh("SingleParticleALD_final") |
| 9 | +ps.Logger.setLogLevel(ps.LogLevel.DEBUG) |
| 10 | + |
| 11 | + |
| 12 | +def run_simulation(gd, filename): |
| 13 | + params = ps.readConfigFile("config.txt") |
| 14 | + geometry = ps.Domain() |
| 15 | + |
| 16 | + # Create the geometry |
| 17 | + boundaryCons = [ |
| 18 | + ps.BoundaryType.REFLECTIVE_BOUNDARY, |
| 19 | + ps.BoundaryType.INFINITE_BOUNDARY, |
| 20 | + ] |
| 21 | + gridDelta = gd |
| 22 | + bounds = [ |
| 23 | + 0.0, |
| 24 | + params["openingWidth"] / 2.0 + params["xPad"] + params["gapLength"], |
| 25 | + -gridDelta, |
| 26 | + params["openingDepth"] + params["gapHeight"] + gridDelta, |
| 27 | + ] |
| 28 | + |
| 29 | + substrate = ls.Domain(bounds, boundaryCons, gridDelta) |
| 30 | + normal = [0.0, 1.0] |
| 31 | + origin = [0.0, params["openingDepth"] + params["gapHeight"]] |
| 32 | + ls.MakeGeometry(substrate, ls.Plane(origin, normal)).apply() |
| 33 | + |
| 34 | + geometry.insertNextLevelSetAsMaterial(substrate, ps.Material.Si) |
| 35 | + |
| 36 | + vertBox = ls.Domain(bounds, boundaryCons, gridDelta) |
| 37 | + minPoint = [-gridDelta, 0.0] |
| 38 | + maxPoint = [ |
| 39 | + params["openingWidth"] / 2.0, |
| 40 | + params["gapHeight"] + params["openingDepth"] + gridDelta, |
| 41 | + ] |
| 42 | + ls.MakeGeometry(vertBox, ls.Box(minPoint, maxPoint)).apply() |
| 43 | + |
| 44 | + geometry.applyBooleanOperation(vertBox, ls.BooleanOperationEnum.RELATIVE_COMPLEMENT) |
| 45 | + |
| 46 | + horiBox = ls.Domain(bounds, boundaryCons, gridDelta) |
| 47 | + minPoint = [params["openingWidth"] / 2.0 - gridDelta, 0.0] |
| 48 | + maxPoint = [params["openingWidth"] / 2.0 + params["gapLength"], params["gapHeight"]] |
| 49 | + ls.MakeGeometry(horiBox, ls.Box(minPoint, maxPoint)).apply() |
| 50 | + geometry.applyBooleanOperation(horiBox, ls.BooleanOperationEnum.RELATIVE_COMPLEMENT) |
| 51 | + |
| 52 | + geometry.saveSurfaceMesh("SingleParticleALD_initial") |
| 53 | + |
| 54 | + model = ps.SingleParticleProcess(rate=1.0, stickingProbability=1e-4) |
| 55 | + |
| 56 | + geometry.duplicateTopLevelSet(ps.Material.Al2O3) |
| 57 | + |
| 58 | + gasMFP = ps.constants.gasMeanFreePath( |
| 59 | + params["pressure"], params["temperature"], params["diameter"] |
| 60 | + ) |
| 61 | + print("Mean free path: ", gasMFP, " um") |
| 62 | + |
| 63 | + model = ps.SingleParticleALD( |
| 64 | + stickingProbability=params["stickingProbability"], |
| 65 | + numCycles=int(params["numCycles"]), |
| 66 | + growthPerCycle=params["growthPerCycle"], |
| 67 | + totalCycles=int(params["totalCycles"]), |
| 68 | + coverageTimeStep=params["coverageTimeStep"], |
| 69 | + evFlux=params["evFlux"], |
| 70 | + inFlux=params["inFlux"], |
| 71 | + s0=params["s0"], |
| 72 | + gasMFP=gasMFP, |
| 73 | + ) |
| 74 | + model.setProcessName(filename) |
| 75 | + |
| 76 | + alpParams = ps.AtomicLayerProcessParameters() |
| 77 | + alpParams.pulseTime = params["pulseTime"] |
| 78 | + alpParams.coverageTimeStep = params["coverageTimeStep"] |
| 79 | + alpParams.numCycles = 1 |
| 80 | + |
| 81 | + p = ps.Process(geometry, model, 1.0) |
| 82 | + p.setParameters(alpParams) |
| 83 | + p.setFluxEngineType(ps.FluxEngineType.GPU_TRIANGLE) |
| 84 | + p.apply() |
| 85 | + |
| 86 | + # flux = p.calculateFlux() |
| 87 | + |
| 88 | + # points = np.array(flux.getNodes()) |
| 89 | + # fluxValues = np.array(flux.getCellData().getScalarData("particleFlux", True)) |
| 90 | + |
| 91 | + # cuts = points[:, 1] < 0.25 |
| 92 | + # points = points[cuts] |
| 93 | + # fluxValues = fluxValues[cuts] |
| 94 | + |
| 95 | + # ps.ls.VTKWriter(flux, filename).apply() |
| 96 | + |
| 97 | + mesh = ps.ls.Mesh() |
| 98 | + ps.ToDiskMesh(geometry, mesh).apply() |
| 99 | + points = np.array(mesh.getNodes()) |
| 100 | + cuts = points[:, 1] < 0.25 |
| 101 | + points = points[cuts] |
| 102 | + return points |
| 103 | + # return points, fluxValues |
| 104 | + |
| 105 | + |
| 106 | +p = run_simulation(0.1, "flux_0p1") |
| 107 | +plt.plot(p[:, 0], p[:, 1], "--") |
| 108 | +p = run_simulation(0.01, "flux_0p01") |
| 109 | +plt.plot(p[:, 0], p[:, 1], ".-") |
| 110 | +p = run_simulation(0.05, "flux_0p05") |
| 111 | +plt.plot(p[:, 0], p[:, 1], "-") |
| 112 | +plt.show() |
| 113 | + |
| 114 | + |
| 115 | +# rayParams = ps.RayTracingParameters() |
| 116 | +# rayParams.raysPerPoint = int(params["numRaysPerPoint"]) |
| 117 | + |
| 118 | +# ALP = ps.Process(geometry, model) |
| 119 | +# ALP.setParameters(rayParams) |
| 120 | +# ALP.setParameters(alpParams) |
| 121 | +# ALP.apply() |
| 122 | + |
| 123 | +# ## TODO: Implement MeasureProfile in Python |
| 124 | +# # MeasureProfile<NumericType, D>(domain, params.get("gapHeight") / 2.) |
| 125 | +# # .save(params.get<std::string>("outputFile")); |
| 126 | + |
| 127 | +# geometry.saveVolumeMesh("SingleParticleALD_final") |
0 commit comments