> For the complete documentation index, see [llms.txt](https://applied-physics.gitbook.io/warp-factory/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://applied-physics.gitbook.io/warp-factory/examples/energy-tensor/t1-first-energy-tensor.md).

# T1 - First Energy Tensor

## Calculating The Stress-Energy Tensor For a Metric

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

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

{% endcode %}

## Compute Energy Tensor

The stress-energy-momentum tensor can be calculated simply by calling `getEnergyTensor(Metric)`

{% code lineNumbers="true" %}

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

{% endcode %}

## Basic Plotting

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

```matlab
% Plotting Metric
clf
for i = 1:4
    for j = 1:4
        h = nexttile;
        surfq(Metric.tensor{i,j}(1,:,:,round(worldCenter(4))),'EdgeColor','none')
        title(num2str(i) + "," + num2str(j))
    end
end
sgtitle(Metric.name)

% Plotting Energy Tensor
clf
for i = 1:4
    for j = 1:4
        h = nexttile;
        surfq(EnergyTensor.tensor{i,j}(1,:,:,round(worldCenter(4))),'EdgeColor','none')
        title(num2str(i) + "," + num2str(j))
    end
end
sgtitle(Metric.name + " Energy Tensor")
```

{% endcode %}

## Calculating the Eulerian Stress-Energy Tensor

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

```matlab
% Convert to Eulerian Frame
EnergyTensorEulerian = doFrameTransfer(Metric,EnergyTensor,"Eulerian");

% Plotting Eulerian Energy Tensor
clf
for i = 1:4
    for j = 1:4
        h = nexttile;
        surfq(EnergyTensorEulerian.tensor{i,j}(1,:,:,round(worldCenter(4))),'EdgeColor','none')
        title(num2str(i) + "," + num2str(j))
    end
end
sgtitle(Metric.name + " Eulerian Energy Tensor")
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://applied-physics.gitbook.io/warp-factory/examples/energy-tensor/t1-first-energy-tensor.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
