Skip to content

Commit

Permalink
Add phased array methods
Browse files Browse the repository at this point in the history
Add methods for calculating phased array using array factor and average embedded pattern.
  • Loading branch information
christianheina committed Mar 12, 2024
1 parent 6bc8530 commit 61bbb54
Show file tree
Hide file tree
Showing 4 changed files with 522,896 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<antenna-commons.version>0.0.2</antenna-commons.version>
<jantenna-commons.version>0.0.3</jantenna-commons.version>
<testng.version>7.9.0</testng.version>
<formatter-maven-plugin.version>2.16.0</formatter-maven-plugin.version>
<maven-release-plugin.version>3.0.0-M4</maven-release-plugin.version>
Expand All @@ -43,7 +43,7 @@
<dependency>
<groupId>com.christianheina.communication</groupId>
<artifactId>jantenna-commons</artifactId>
<version>${antenna-commons.version}</version>
<version>${jantenna-commons.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,61 @@ private static CompletableFuture<Complex> calculateArrayFactorAsync(ExecutorServ
return future;
}

/**
* Create phased array. <br>
* Both {@code arrayFactor} and {@code averageEmbeddedAntennaField} must contain same angles.
*
* @param averageEmbeddedAntennaField
* the average embedded field.
* @param arrayFactor
* the array factor field.
*
* @return
*/
public static Field newPhasedArray(Field averageEmbeddedAntennaField, Field arrayFactor) {
return averageEmbeddedAntennaField.multiply(arrayFactor);
}

/**
* Create phased array
*
* @param averageEmbeddedAntennaField
* the average embedded field. Must contain same angles as the {@code angles}
* @param frequency
* wavelength
* @param antennaArray
* antenna array to use when creating phased array
* @param angles
* angles used in the created phased array
*
* @return a field containing the phased array
*/
public static Field newPhasedArrayAsync(Field averageEmbeddedAntennaField, double frequency,
AntennaArray antennaArray, List<ThetaPhi> angles) {
Field arrayFactor = newArrayFactorAsync(frequency, antennaArray, angles);
return newPhasedArray(averageEmbeddedAntennaField, arrayFactor);
}

/**
* Create phased array
*
* @param averageEmbeddedAntennaField
* the average embedded field. Must contain same angles as the {@code angles}
* @param executorService
* the ExecutorService used for asynchronous array factor calculations
* @param frequency
* wavelength
* @param antennaArray
* antenna array to use when creating phased array
* @param angles
* angles used in the created phased array
*
* @return a field containing the phased array
*/
public static Field newPhasedArrayAsync(Field averageEmbeddedAntennaField, ExecutorService executorService,
double frequency, AntennaArray antennaArray, List<ThetaPhi> angles) {
Field arrayFactor = newArrayFactorAsync(executorService, frequency, antennaArray, angles);
return newPhasedArray(averageEmbeddedAntennaField, arrayFactor);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.christianheina.communication.jantenna.phasedarray;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
Expand All @@ -38,6 +40,9 @@
@SuppressWarnings("javadoc")
public class PhasedArrayAntennaTest {

private static final String AVERAGE_EMBEDDED_FIELD_PATH = new File(PhasedArrayAntennaTest.class.getClassLoader()
.getResource("example_sphere_gaussian_model_field.json").getFile()).getPath();

@Test
public void newArrayFactorAsyncSuppliedExecutorServiceTest() {
double freq = 28 * Math.pow(10, 9);
Expand Down Expand Up @@ -101,4 +106,98 @@ public void newArrayFactorAsyncTest() {

}

@Test
public void newPhasedArrayTest() throws IOException {
double freq = 28 * Math.pow(10, 9);
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithmFromLambda(Util.calculateLambda(freq), steeringAngle));
Field arrayFactor = PhasedArrayAntenna.newArrayFactorAsync(Executors.newSingleThreadExecutor(), freq,
antennaArray, angleList);
Field averageEmbeddedField = Field.loadJson(AVERAGE_EMBEDDED_FIELD_PATH);
Field phasedArrayField = PhasedArrayAntenna.newPhasedArray(averageEmbeddedField, arrayFactor);
Assert.assertEquals(phasedArrayField.getThetaPhiList().size(), angleList.size());
phasedArrayField.getAvailableElectricFields().forEach(electricFieldName -> {
List<Complex> electricFieldList = phasedArrayField.getElectricField(electricFieldName);
double max = Double.MIN_VALUE;
List<ThetaPhi> maxAngleList = new ArrayList<>();
for (int i = 0; i < electricFieldList.size(); i++) {
if (electricFieldList.get(i).abs() >= max) {
max = electricFieldList.get(i).abs();
maxAngleList.add(angleList.get(i));
}
}
boolean hasAngleInList = false;
for (ThetaPhi thetaPhi : maxAngleList) {
if (thetaPhi.getTheta() == steeringAngle.getTheta() && thetaPhi.getPhi() == steeringAngle.getPhi()) {
hasAngleInList = true;
}
}
Assert.assertTrue(hasAngleInList);
});
}

@Test
public void newPhasedArrayAsyncTest() throws IOException {
double freq = 28 * Math.pow(10, 9);
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithmFromLambda(Util.calculateLambda(freq), steeringAngle));
Field averageEmbeddedField = Field.loadJson(AVERAGE_EMBEDDED_FIELD_PATH);
Field phasedArrayField = PhasedArrayAntenna.newPhasedArrayAsync(averageEmbeddedField, freq, antennaArray,
angleList);
Assert.assertEquals(phasedArrayField.getThetaPhiList().size(), angleList.size());
phasedArrayField.getAvailableElectricFields().forEach(electricFieldName -> {
List<Complex> electricFieldList = phasedArrayField.getElectricField(electricFieldName);
double max = Double.MIN_VALUE;
List<ThetaPhi> maxAngleList = new ArrayList<>();
for (int i = 0; i < electricFieldList.size(); i++) {
if (electricFieldList.get(i).abs() >= max) {
max = electricFieldList.get(i).abs();
maxAngleList.add(angleList.get(i));
}
}
boolean hasAngleInList = false;
for (ThetaPhi thetaPhi : maxAngleList) {
if (thetaPhi.getTheta() == steeringAngle.getTheta() && thetaPhi.getPhi() == steeringAngle.getPhi()) {
hasAngleInList = true;
}
}
Assert.assertTrue(hasAngleInList);
});
}

@Test
public void newPhasedArrayAsyncSuppliedExecutorServiceTest() throws IOException {
double freq = 28 * Math.pow(10, 9);
List<ThetaPhi> angleList = ThetaPhi.equallySpacedSphere(1);
ThetaPhi steeringAngle = ThetaPhi.fromDegrees(90, 0);
AntennaArray antennaArray = AntennaArray.fromEquallySpacedArray(1, 24, 16, 0.5, freq,
WeightAlgorithm.newConjugateWeightAlgorithmFromLambda(Util.calculateLambda(freq), steeringAngle));
Field averageEmbeddedField = Field.loadJson(AVERAGE_EMBEDDED_FIELD_PATH);
Field phasedArrayField = PhasedArrayAntenna.newPhasedArrayAsync(averageEmbeddedField,
Executors.newSingleThreadExecutor(), freq, antennaArray, angleList);
Assert.assertEquals(phasedArrayField.getThetaPhiList().size(), angleList.size());
phasedArrayField.getAvailableElectricFields().forEach(electricFieldName -> {
List<Complex> electricFieldList = phasedArrayField.getElectricField(electricFieldName);
double max = Double.MIN_VALUE;
List<ThetaPhi> maxAngleList = new ArrayList<>();
for (int i = 0; i < electricFieldList.size(); i++) {
if (electricFieldList.get(i).abs() >= max) {
max = electricFieldList.get(i).abs();
maxAngleList.add(angleList.get(i));
}
}
boolean hasAngleInList = false;
for (ThetaPhi thetaPhi : maxAngleList) {
if (thetaPhi.getTheta() == steeringAngle.getTheta() && thetaPhi.getPhi() == steeringAngle.getPhi()) {
hasAngleInList = true;
}
}
Assert.assertTrue(hasAngleInList);
});
}

}
Loading

0 comments on commit 61bbb54

Please sign in to comment.