To solve this optimization problem, we need to define the decision variables, objective function, and constraints. Let's break down the problem step by step:

1. **Decision Variables**:
   - \(x_p\): Number of pens bought (and sold, assuming all inventory is sold).
   - \(x_c\): Number of pencils bought (and sold).

2. **Objective Function**:
   - The objective is to maximize profit. Profit from each pen sold is $3, and from each pencil is $1.
   - Therefore, the total profit \(P\) can be represented as: \(P = 3x_p + x_c\).

3. **Constraints**:
   - **Cost Constraint**: The store owner can spend at most $500 on inventory. Each pen costs $2, and each pencil costs $1.
     - \(2x_p + x_c \leq 500\)
   - **Pen Sales Lower Bound**: At least 100 pens are sold.
     - \(x_p \geq 100\)
   - **Pen Sales Upper Bound**: At most 150 pens are sold.
     - \(x_p \leq 150\)
   - **Pencil Sales Constraint**: The number of pencils sold is at most twice the amount of pens sold.
     - \(x_c \leq 2x_p\)

4. **Non-Negativity Constraints**:
   - Since we cannot buy or sell a negative quantity of items, both \(x_p\) and \(x_c\) must be non-negative.

Given these definitions, we can formulate the optimization problem as follows:

Maximize: \(3x_p + x_c\)

Subject to:
- \(2x_p + x_c \leq 500\)
- \(100 \leq x_p \leq 150\)
- \(x_c \leq 2x_p\)
- \(x_p, x_c \geq 0\)

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

# Create a new model
m = Model("Stationary_Store_Profit")

# Decision Variables
x_p = m.addVar(lb=100, ub=150, vtype=GRB.INTEGER, name="pens")
x_c = m.addVar(vtype=GRB.INTEGER, name="pencils")

# Objective Function: Maximize profit
m.setObjective(3*x_p + x_c, GRB.MAXIMIZE)

# Constraints
m.addConstr(2*x_p + x_c <= 500, "cost_constraint")
m.addConstr(x_c <= 2*x_p, "pencil_sales_constraint")

# Optimize the model
m.optimize()

# Print solution
if m.status == GRB.OPTIMAL:
    print("Optimal solution found.")
    print(f"Buy and sell {x_p.x} pens.")
    print(f"Buy and sell {x_c.x} pencils.")
    print(f"Maximum profit: {m.objVal}")
else:
    print("No optimal solution found.")

```