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

New shape of the target #745

Open
mimboch opened this issue Nov 11, 2024 · 6 comments
Open

New shape of the target #745

mimboch opened this issue Nov 11, 2024 · 6 comments

Comments

@mimboch
Copy link

mimboch commented Nov 11, 2024

Hello,
I'm trying to simulate the following shape of the jet gas target, with circular ends and a flat section in the middle .
I would be very grateful if anyone could give me a hand.
Thank you in advance.

gas jet target

@Status-Mirror
Copy link
Collaborator

Hey @mimboch,

I've adapted the basic target demo using expressions from the maths parser to obtain the following target:

ball_rod_target

which was created with this input deck:

begin:control
    nx = 800
    ny = 120
    t_end = 1.0e-15
    x_min = -20e-6
    x_max = 20e-6
    y_min = -3.0e-6
    y_max = 3.0e-6
    stdout_frequency = 100
    npart = 10 * nx * ny
end:control

begin:boundaries
    bc_x_min = open
    bc_x_max = open
    bc_y_min = open
    bc_y_max = open
end:boundaries

begin:constant
    targ_length = 25e-6
    targ_rod_thickness = 600e-9
    targ_ball_radius = 2e-6
    targ_dens = 1.0e24
end:constant

begin:species
    name = Electron
    mass = 1.0
    charge = -1.0
    frac = 0.8
    temp_ev = 1000
    
    # Rod part
    density = if (abs(y) lt 0.5*targ_rod_thickness \
                  and abs(x) lt (targ_length/2 - targ_ball_radius), \
                  targ_dens, 0)
    
    # Balls
    density = if ((abs(x)-targ_length/2 + targ_ball_radius)^2 + \
                   y^2 lt targ_ball_radius^2, targ_dens, density(Electron))
end:species

begin:species
    name = Carbon
    mass = 22033.0
    charge = 6.0
    frac = 0.2
    density = density(Electron) / 6
    temp_ev = 1000
end:species

begin:output
    dt_snapshot = t_end
    number_density = always
end:output

Hope this helps,
Stuart

@mimboch
Copy link
Author

mimboch commented Nov 12, 2024

Thank you so much for your assistance .

@mimboch mimboch closed this as completed Nov 12, 2024
@mimboch mimboch reopened this Nov 19, 2024
@mimboch
Copy link
Author

mimboch commented Nov 19, 2024

Hello,
I should have a smooth transition between the circles and the flat section, as shown in the attached picture. I am trying to achieve this with Expo functions, but it didn’t work.
Could you please help me again?
Thank you in advance.
profile_Y

@Status-Mirror
Copy link
Collaborator

Can you be more specific about the curve-shape? For an exponential, I would need to know where you want it to start from, which point on the circle you want it to end, and the exponential scale-length $k$, for a functional form $\exp(x/k)$.

If the older ball-rod target above doesn't work for you, then your results must be sensitive to the nature of this curve. If I just give you a random curve, it will probably have the same problem as the simple ball-rod.

@mimboch
Copy link
Author

mimboch commented Nov 20, 2024

Hello,
Thank you for your reply; I really appreciate it.
Yes, you are absolutely right, but it is not necessarily the goal is to have these curves. For example, I could use a decreasing exponential function from 2 (center of the circle) to 5 µm on the left side and an increasing exponential function from 19 to 23 µm on the right side, with an exponential scale length k=2μm.

@mimboch
Copy link
Author

mimboch commented Nov 25, 2024

Hello Stuart,
I succeeded in plotting the desired profile by using the following MATLAB code, but when I tried to incorporate the target density (30.n_c for 800 nm wavelength), I often return to the first shape (without curves). Could you please help me further?
` % Constants
% Rectangles
centralRectPosition = [3, -1]; % Bottom-left corner of the central rectangle
centralRectWidth = 21;
centralRectHeight = 2;

leftCirclePosition = [0, -2]; % Bottom-left corner of the left circular end
rightCirclePosition = [21, -2]; % Bottom-left corner of the right circular end
circleDiameter = 4; % Diameter of the circular ends
circleCurvature = [1, 1]; % Curvature to make it a circle

% Arcs
arcRadius = 2; % Radius for both top and bottom arcs
topArcStartPoint = [2.8; 1.8]; % Start point of the top arc
topArcEndPoint = [4.8; 1]; % End point of the top arc
bottomArcStartPoint = [4.8; -1]; % Start point of the bottom arc
bottomArcEndPoint = [2.8; -1.8]; % End point of the bottom arc

% Transformations
translationDistance = 21; % Distance to translate the left shape to the right
rotationAngle = 180; % Rotation angle in degrees
rotationPivot = [23, 0]; % Pivot point for rotation

% Visualization
xAxisLimits = [-5, 30];
yAxisLimits = [-2.5, 2.5];
shapeColor = [0, 0, 1]; % Blue color for the shapes

figure;
% Central rectangle
rectangle("Position", [centralRectPosition, centralRectWidth, centralRectHeight], ...
"FaceColor", shapeColor, "EdgeColor", "none");

hold on;
% Left circular end
rectangle("Position", [leftCirclePosition, circleDiameter, circleDiameter], ...
"FaceColor", shapeColor, "Curvature", circleCurvature, "EdgeColor", "none");

% Right circular end
rectangle("Position", [rightCirclePosition, circleDiameter, circleDiameter], ...
"FaceColor", shapeColor, "Curvature", circleCurvature, "EdgeColor", "none");

% Top and bottom arcs
[xtop, ytop] = topArc(topArcStartPoint, topArcEndPoint, arcRadius);
[xbot, ybot] = bottomArc(bottomArcStartPoint, bottomArcEndPoint, arcRadius);

% Combine arcs into a shape
x_arc = [xtop xbot];
y_arc = [ytop ybot];
left = polyshape(x_arc, y_arc);

% Transform the left shape to create the right shape
right = translate(left, translationDistance, 0); % Move to the right
right = rotate(right, rotationAngle, rotationPivot); % Rotate around the pivot

% Plot the shapes
plot(left, "FaceColor", shapeColor, "FaceAlpha", 1, "EdgeColor", "none");
plot(right, "FaceColor", shapeColor, "FaceAlpha", 1, "EdgeColor", "none");

% Visualization settings
axis equal;
xlim(xAxisLimits);
ylim(yAxisLimits);
xlabel('X (\mum)');
ylabel('Y (\mum)');
grid on;

% Functions
function [x, y] = bottomArc(startPoint, endPoint, radius)
d = norm(endPoint-startPoint);
C = (endPoint+startPoint)/2+sqrt(radius^2-d^2/4)/d*[0,-1;1,0](endPoint-startPoint);
a = atan2(startPoint(2)-C(2),startPoint(1)-C(1));
b = atan2(endPoint(2)-C(2),endPoint(1)-C(1));
b = mod(b-a,2
pi)+a; % Ensure that arc moves counterclockwise
t = linspace(a,b,1000);
x = C(1)+radiuscos(t);
y = C(2)+radius
sin(t);
end

function [x, y] = topArc(startPoint, endPoint, radius)
d = norm(endPoint-startPoint);
C = (endPoint+startPoint)/2+sqrt(radius^2-d^2/4)/d*[0,-1;1,0](endPoint-startPoint);
a = atan2(startPoint(2)-C(2),startPoint(1)-C(1));
b = atan2(endPoint(2)-C(2),endPoint(1)-C(1));
b = mod(b-a,2
pi)+a; % Ensure that arc moves counterclockwise
t = linspace(a,b,1000);
x = C(1)+radiuscos(t);
y = C(2)+radius
sin(t);
end`

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

No branches or pull requests

2 participants