# A1 - Energy Conditions

## Computing Energy Conditions

### Get Metric and Energy Tensor

{% code overflow="wrap" lineNumbers="true" %}

```matlab
%% Alcubierre
gridSize = [1 20 20 20];
worldCenter = (gridSize+1)./2;
velocity = 0.5;
R = 5;
sigma = 0.5;
Metric = metricGet_AlcubierreComoving(gridSize,worldCenter,velocity,R,sigma);

% Compute energy tensor
EnergyTensor = getEnergyTensor(Metric);
```

{% endcode %}

### Get Energy Conditions Map

{% code lineNumbers="true" %}

```matlab
[nullEnergyCondition] = getEnergyConditions(EnergyTensor,Metric,"Null");
[weakEnergyCondition] = getEnergyConditions(EnergyTensor,Metric,"Weak");
[strongEnergyCondition] = getEnergyConditions(EnergyTensor,Metric,"Strong");
[dominantEnergyCondition] = getEnergyConditions(EnergyTensor,Metric,"Dominant");
```

{% endcode %}

### Plot Energy Conditions

{% code lineNumbers="true" %}

```matlab
surfq(nullEnergyCondition(1,:,:,10),'EdgeColor','none')
title('Null')

surfq(weakEnergyCondition(1,:,:,10),'EdgeColor','none')
title('Weak')

surfq(strongEnergyCondition(1,:,:,10),'EdgeColor','none')
title('Strong')

surfq(strongEnergyCondition(1,:,:,10),'EdgeColor','none')
title('Domiant')
```

{% endcode %}

### Returning Vectors

You can also return the energy conditions per vector sampled at each point in the spacetime by specifying the return vector option to true.

{% code overflow="wrap" lineNumbers="true" %}

```matlab
numAngularVec = 100;
numTimeVec = 10;

[nullMap, nullVecMap, vectorField] = getEnergyConditions(EnergyTensor,Metric,"Null",numAngularVec,numTimeVec,1);
```

{% endcode %}

We can now plot the violation amount scaled to a quiver plot along each of the sampled directions.

{% code overflow="wrap" lineNumbers="true" %}

```matlab
% Normalize the violation amount for plotting
nullVecMap = nullVecMap./max(abs(nullVecMap),[],'all');

% Define the spacetime point to sample
samplePoint = [1,5,5,5];

figure()
hold on
for i = 1:size(vectorField,2)
    quiver3(0,0,0, ...
        vectorField(2,i), vectorField(3,i), vectorField(4,i), ...
        nullVecMap(samplePoint(1),samplePoint(2),samplePoint(3),samplePoint(4),i),'r')     
end
title('Normalized Null Violation For Observer Orientations')
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://applied-physics.gitbook.io/warp-factory/examples/analysis/a1-energy-conditions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
