Handling cases when a script interpolates a location outside of the mesh, and providing a meaningful error message
This commit is contained in:
parent
615106144a
commit
d147155c8b
@ -152,6 +152,7 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
% calculate position of the voltage probes
|
% calculate position of the voltage probes
|
||||||
|
try
|
||||||
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
||||||
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
||||||
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
||||||
@ -174,6 +175,9 @@ v3_start = v2_start;
|
|||||||
v3_stop = v2_stop;
|
v3_stop = v2_stop;
|
||||||
v3_start(idx_prop) = meshlines(3);
|
v3_start(idx_prop) = meshlines(3);
|
||||||
v3_stop(idx_prop) = meshlines(3);
|
v3_stop(idx_prop) = meshlines(3);
|
||||||
|
catch
|
||||||
|
error('Unable to place voltage probe on mesh; check the location of the CPW and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
width_add_start = [0 0 0];
|
width_add_start = [0 0 0];
|
||||||
width_add_stop = [0 0 0];
|
width_add_stop = [0 0 0];
|
||||||
@ -209,6 +213,7 @@ CSX = AddProbe( CSX, port.U_filename{3,2}, 0, 'weight', weight );
|
|||||||
CSX = AddBox( CSX, port.U_filename{3,2}, prio, v3_start+width_add_start, v3_stop+width_add_stop );
|
CSX = AddBox( CSX, port.U_filename{3,2}, prio, v3_start+width_add_start, v3_stop+width_add_stop );
|
||||||
|
|
||||||
% calculate position of the current probes
|
% calculate position of the current probes
|
||||||
|
try
|
||||||
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
||||||
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
||||||
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
||||||
@ -222,6 +227,9 @@ i2_start = i1_start;
|
|||||||
i2_stop = i1_stop;
|
i2_stop = i1_stop;
|
||||||
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
||||||
i2_stop(idx_prop) = i2_start(idx_prop);
|
i2_stop(idx_prop) = i2_start(idx_prop);
|
||||||
|
catch
|
||||||
|
error('Unable to place current probe on mesh; check the location of the CPW and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% create the curr-probes
|
% create the curr-probes
|
||||||
weight = direction;
|
weight = direction;
|
||||||
@ -248,6 +256,7 @@ port.measplanepos = abs(v2_start(idx_prop) - start(idx_prop))*port.LengthScale;
|
|||||||
% port
|
% port
|
||||||
|
|
||||||
% create excitation (if enabled) and port resistance
|
% create excitation (if enabled) and port resistance
|
||||||
|
try
|
||||||
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
||||||
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
||||||
ex_start(idx_width) = (nstart(idx_width)+nstop(idx_width))/2;
|
ex_start(idx_width) = (nstart(idx_width)+nstop(idx_width))/2;
|
||||||
@ -255,6 +264,9 @@ ex_start(idx_height) = nstart(idx_height);
|
|||||||
ex_stop(idx_prop) = ex_start(idx_prop);
|
ex_stop(idx_prop) = ex_start(idx_prop);
|
||||||
ex_stop(idx_width) = (nstart(idx_width)+nstop(idx_width))/2;
|
ex_stop(idx_width) = (nstart(idx_width)+nstop(idx_width))/2;
|
||||||
ex_stop(idx_height) = nstop(idx_height);
|
ex_stop(idx_height) = nstop(idx_height);
|
||||||
|
catch
|
||||||
|
error('Unable to place excitation on mesh; check the location of the CPW and the excitation (FeedShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
port.excite = 0;
|
port.excite = 0;
|
||||||
if excite
|
if excite
|
||||||
|
@ -114,6 +114,7 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
% calculate position of the voltage probes
|
% calculate position of the voltage probes
|
||||||
|
try
|
||||||
mesh{1} = sort(unique(CSX.RectilinearGrid.XLines));
|
mesh{1} = sort(unique(CSX.RectilinearGrid.XLines));
|
||||||
mesh{2} = sort(unique(CSX.RectilinearGrid.YLines));
|
mesh{2} = sort(unique(CSX.RectilinearGrid.YLines));
|
||||||
mesh{3} = sort(unique(CSX.RectilinearGrid.ZLines));
|
mesh{3} = sort(unique(CSX.RectilinearGrid.ZLines));
|
||||||
@ -135,6 +136,9 @@ v3_start = v2_start;
|
|||||||
v3_stop = v2_stop;
|
v3_stop = v2_stop;
|
||||||
v3_start(idx_prop_n) = meshlines(3);
|
v3_start(idx_prop_n) = meshlines(3);
|
||||||
v3_stop(idx_prop_n) = meshlines(3);
|
v3_stop(idx_prop_n) = meshlines(3);
|
||||||
|
catch
|
||||||
|
error('Unable to place voltage probe on mesh; check the location of the port and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% calculate position of the current probes
|
% calculate position of the current probes
|
||||||
i1_start(idx_prop_n) = 0.5*(meshlines(1)+meshlines(2));
|
i1_start(idx_prop_n) = 0.5*(meshlines(1)+meshlines(2));
|
||||||
@ -184,12 +188,16 @@ port.r_i = r_i;
|
|||||||
port.r_o = r_o;
|
port.r_o = r_o;
|
||||||
|
|
||||||
% create excitation (if enabled) and port resistance
|
% create excitation (if enabled) and port resistance
|
||||||
|
try
|
||||||
meshline = interp1( mesh{idx_prop_n}, 1:numel(mesh{idx_prop_n}), start(idx_prop_n) + feed_shift*direction, 'nearest' );
|
meshline = interp1( mesh{idx_prop_n}, 1:numel(mesh{idx_prop_n}), start(idx_prop_n) + feed_shift*direction, 'nearest' );
|
||||||
min_cell_prop = min(diff(mesh{idx_prop_n}));
|
min_cell_prop = min(diff(mesh{idx_prop_n}));
|
||||||
ex_start = start;
|
ex_start = start;
|
||||||
ex_start(idx_prop_n) = mesh{idx_prop_n}(meshline) - 0.01*min_cell_prop;
|
ex_start(idx_prop_n) = mesh{idx_prop_n}(meshline) - 0.01*min_cell_prop;
|
||||||
ex_stop = ex_start;
|
ex_stop = ex_start;
|
||||||
ex_stop(idx_prop_n) = mesh{idx_prop_n}(meshline) + 0.01*min_cell_prop;
|
ex_stop(idx_prop_n) = mesh{idx_prop_n}(meshline) + 0.01*min_cell_prop;
|
||||||
|
catch
|
||||||
|
error('Unable to place excitation on mesh; check the location of the port and the excitation (FeedShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
port.excite = 0;
|
port.excite = 0;
|
||||||
if (excite_amp~=0)
|
if (excite_amp~=0)
|
||||||
|
@ -78,6 +78,7 @@ for n=1:3
|
|||||||
end
|
end
|
||||||
|
|
||||||
% calculate position
|
% calculate position
|
||||||
|
try
|
||||||
port_start_idx = start_idx;
|
port_start_idx = start_idx;
|
||||||
port_stop_idx = stop_idx;
|
port_stop_idx = stop_idx;
|
||||||
if abs(start_idx(dir) - stop_idx(dir)) ~= 1
|
if abs(start_idx(dir) - stop_idx(dir)) ~= 1
|
||||||
@ -96,6 +97,9 @@ if abs(start_idx(dir) - stop_idx(dir)) ~= 1
|
|||||||
CSX = AddCurve( CSX, metalname, prio, [nstart.' [mesh{1}(port_start_idx(1));mesh{2}(port_start_idx(2));mesh{3}(port_start_idx(3))]] );
|
CSX = AddCurve( CSX, metalname, prio, [nstart.' [mesh{1}(port_start_idx(1));mesh{2}(port_start_idx(2));mesh{3}(port_start_idx(3))]] );
|
||||||
CSX = AddCurve( CSX, metalname, prio, [nstop.' [mesh{1}(port_stop_idx(1));mesh{2}(port_stop_idx(2));mesh{3}(port_stop_idx(3))]] );
|
CSX = AddCurve( CSX, metalname, prio, [nstop.' [mesh{1}(port_stop_idx(1));mesh{2}(port_stop_idx(2));mesh{3}(port_stop_idx(3))]] );
|
||||||
end
|
end
|
||||||
|
catch
|
||||||
|
error('Unable to place port on mesh; check the location of the port, and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% calculate position of resistive material
|
% calculate position of resistive material
|
||||||
delta1_n = mesh{dir1}(port_start_idx(dir1)) - mesh{dir1}(port_start_idx(dir1)-1);
|
delta1_n = mesh{dir1}(port_start_idx(dir1)) - mesh{dir1}(port_start_idx(dir1)-1);
|
||||||
|
@ -156,6 +156,7 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
% calculate position of the voltage probes
|
% calculate position of the voltage probes
|
||||||
|
try
|
||||||
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
||||||
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
||||||
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
||||||
@ -179,8 +180,12 @@ v3_start = v2_start;
|
|||||||
v3_stop = v2_stop;
|
v3_stop = v2_stop;
|
||||||
v3_start(idx_prop) = meshlines(3);
|
v3_start(idx_prop) = meshlines(3);
|
||||||
v3_stop(idx_prop) = meshlines(3);
|
v3_stop(idx_prop) = meshlines(3);
|
||||||
|
catch
|
||||||
|
error('Unable to place voltage probe on mesh; check the location of the MSL and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% calculate position of the current probes
|
% calculate position of the current probes
|
||||||
|
try
|
||||||
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
||||||
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
||||||
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
||||||
@ -194,6 +199,9 @@ i2_start = i1_start;
|
|||||||
i2_stop = i1_stop;
|
i2_stop = i1_stop;
|
||||||
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
||||||
i2_stop(idx_prop) = i2_start(idx_prop);
|
i2_stop(idx_prop) = i2_start(idx_prop);
|
||||||
|
catch
|
||||||
|
error('Unable to place current probe on mesh; check the location of the MSL, and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% create the probes
|
% create the probes
|
||||||
port.U_filename{1} = [PortNamePrefix 'port_ut' num2str(portnr) 'A'];
|
port.U_filename{1} = [PortNamePrefix 'port_ut' num2str(portnr) 'A'];
|
||||||
@ -232,6 +240,7 @@ port.measplanepos = abs(v2_start(idx_prop) - start(idx_prop))*port.LengthScale;
|
|||||||
% port
|
% port
|
||||||
|
|
||||||
% create excitation (if enabled) and port resistance
|
% create excitation (if enabled) and port resistance
|
||||||
|
try
|
||||||
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
||||||
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
||||||
ex_start(idx_width) = nstart(idx_width);
|
ex_start(idx_width) = nstart(idx_width);
|
||||||
@ -239,6 +248,9 @@ ex_start(idx_height) = nstart(idx_height);
|
|||||||
ex_stop(idx_prop) = ex_start(idx_prop);
|
ex_stop(idx_prop) = ex_start(idx_prop);
|
||||||
ex_stop(idx_width) = nstop(idx_width);
|
ex_stop(idx_width) = nstop(idx_width);
|
||||||
ex_stop(idx_height) = nstop(idx_height);
|
ex_stop(idx_height) = nstop(idx_height);
|
||||||
|
catch
|
||||||
|
error('Unable to place excitation on mesh; check the location of the MSL and the excitation (FeedShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
port.excite = 0;
|
port.excite = 0;
|
||||||
if excite
|
if excite
|
||||||
|
@ -151,6 +151,7 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
% calculate position of the voltage probes
|
% calculate position of the voltage probes
|
||||||
|
try
|
||||||
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
mesh{1} = sort(CSX.RectilinearGrid.XLines);
|
||||||
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
mesh{2} = sort(CSX.RectilinearGrid.YLines);
|
||||||
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
mesh{3} = sort(CSX.RectilinearGrid.ZLines);
|
||||||
@ -174,6 +175,9 @@ v3_start = v2_start;
|
|||||||
v3_stop = v2_stop;
|
v3_stop = v2_stop;
|
||||||
v3_start(idx_prop) = meshlines(3);
|
v3_start(idx_prop) = meshlines(3);
|
||||||
v3_stop(idx_prop) = meshlines(3);
|
v3_stop(idx_prop) = meshlines(3);
|
||||||
|
catch
|
||||||
|
error('Unable to place voltage probe on mesh; check the location of the stripline and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
height_vector = [0 0 0];
|
height_vector = [0 0 0];
|
||||||
height_vector(idx_height) = height;
|
height_vector(idx_height) = height;
|
||||||
@ -207,6 +211,7 @@ CSX = AddProbe( CSX, port.U_filename{3,2}, 0, 'weight', -1*weight );
|
|||||||
CSX = AddBox( CSX, port.U_filename{3,2}, prio, v3_start, v3_stop-height_vector );
|
CSX = AddBox( CSX, port.U_filename{3,2}, prio, v3_start, v3_stop-height_vector );
|
||||||
|
|
||||||
% calculate position of the current probes
|
% calculate position of the current probes
|
||||||
|
try
|
||||||
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
idx = interp1( mesh{idx_width}, 1:numel(mesh{idx_width}), nstart(idx_width), 'nearest' );
|
||||||
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
i1_start(idx_width) = mesh{idx_width}(idx) - diff(mesh{idx_width}(idx-1:idx))/2;
|
||||||
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
idx = interp1( mesh{idx_height}, 1:numel(mesh{idx_height}), start(idx_height), 'nearest' );
|
||||||
@ -220,6 +225,9 @@ i2_start = i1_start;
|
|||||||
i2_stop = i1_stop;
|
i2_stop = i1_stop;
|
||||||
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
i2_start(idx_prop) = sum(meshlines(2:3))/2;
|
||||||
i2_stop(idx_prop) = i2_start(idx_prop);
|
i2_stop(idx_prop) = i2_start(idx_prop);
|
||||||
|
catch
|
||||||
|
error('Unable to place current probe on mesh; check the location of the stripline and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
% create the curr-probes
|
% create the curr-probes
|
||||||
weight = direction;
|
weight = direction;
|
||||||
@ -246,6 +254,7 @@ port.measplanepos = abs(v2_start(idx_prop) - start(idx_prop))*port.LengthScale;
|
|||||||
% port
|
% port
|
||||||
|
|
||||||
% create excitation (if enabled) and port resistance
|
% create excitation (if enabled) and port resistance
|
||||||
|
try
|
||||||
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
meshline = interp1( mesh{idx_prop}, 1:numel(mesh{idx_prop}), start(idx_prop) + feed_shift*direction, 'nearest' );
|
||||||
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
ex_start(idx_prop) = mesh{idx_prop}(meshline) ;
|
||||||
ex_start(idx_width) = nstart(idx_width);
|
ex_start(idx_width) = nstart(idx_width);
|
||||||
@ -253,6 +262,9 @@ ex_start(idx_height) = nstart(idx_height);
|
|||||||
ex_stop(idx_prop) = ex_start(idx_prop);
|
ex_stop(idx_prop) = ex_start(idx_prop);
|
||||||
ex_stop(idx_width) = nstop(idx_width);
|
ex_stop(idx_width) = nstop(idx_width);
|
||||||
ex_stop(idx_height) = nstop(idx_height);
|
ex_stop(idx_height) = nstop(idx_height);
|
||||||
|
catch
|
||||||
|
error('Unable to place excitation on mesh; check the location of the stripline and the probe (MeasPlaneShift), and make sure that the mesh is large enough');
|
||||||
|
end
|
||||||
|
|
||||||
port.excite = 0;
|
port.excite = 0;
|
||||||
if excite
|
if excite
|
||||||
|
Loading…
Reference in New Issue
Block a user